Skip to content
Home · Sonraki hedefe 100 XP
Son hareketler
Henüz bir öğrenme hareketi yok. İlk derse başlayın.

Programming Fundamentals

PHP: From request to safe response

PHP runs on the server; The generated HTTP response is sent to the browser instead of the resource file. Separating the responsibilities of retrieving data, business rules, and producing output while learning the basics of the language makes subsequent security checks clear.

Bu derste neler var?

SIBERSALDIRI.COM · FOCUSED LESSON

What you will learn

  • Explain the relationship between the request and the Business rule.
  • “Why shouldn't the PHP source file be sent to the browser?” To give a reasoned answer to the question.
  • Changing the example and comparing expected and observed behavior.

How it works and where the trust boundary lies

In a profile request, the type and limit of the entry is first verified, and then the user's ability to view the record is checked. In the final stage, the data is coded according to the output context. No single cleaning function can cover all three responsibilities. The CLI instance allows you to observe the behavior of the function without the need for an HTTP server.

PHP: Flow from request to secure response: Request → Business rule → Secure response
Request → Business rule → Secure response. The diagram shows the relationship; It does not replace the entire application.

Worked example

The following passage makes the concept visible. Evaluate samples containing commands or code in your own separate testing environment, not in the production system. Architectural diagrams and policy examples are not executable programs.

<?php
declare(strict_types=1);
function greet(string $name): string {
    return 'Merhaba, ' . $name;
}
echo greet('Akademi'), PHP_EOL;

Expected result and interpretation

Hello, Academy is written; The function returns a value, echo moves it to the output.

Compare the scenarios

StatusRecommended approachWhy?
CLI calltext appearedDoes not require HTTP session
web formType and authorization checkClient data is not reliable
HTML responseOutput encodingPrevents data from becoming scripted

Practice task

Define separate behavior for empty name. Run it with two different names and empty text and compare the results.

  1. Write down the expected outcome and acceptance condition before the action.
  2. Change a single variable; Record the observation and the medium you used.
  3. Evaluate the result with the comparison table above. Explain which assumption might be wrong if it does not fit.

Common mistake and how to correct it

Do not use HTML coding and SQL parameter binding interchangeably.

Test your understanding

Why shouldn't the PHP source file be sent to the browser?

Answer explained: Source code can reveal hidden configuration and business logic; The correct server configuration will run the code and send only the response.

Continue with related lessons

Technical reference

The explanation and examples of this course have been re-prepared for the academy. The link below is a technical reference to verify details of the technology or security approach used.

Lessons in this section

Programming Fundamentals

XAMPP: Isolated development environment

XAMPP yerel Apache, PHP ve veritabanı bileşenlerini birlikte denemenizi kolaylaştırır. Servisin çalışması ile projenin doğru URL a

2 min read
↗
Programming Fundamentals

VS Code: Reproducible workspace

Editör kodu düzenler; uygulamayı çalıştıran yorumlayıcının yerini almaz. Klasör olarak açılmış bir proje, doğru terminal dizini ve

2 min read
↗
Programming Fundamentals

PHP files: Entry point and responsibility

Bir PHP dosyası isteği karşılayan giriş noktası veya yeniden kullanılabilir işlevleri tanımlayan bileşen olabilir. Bu ayrım küçük

2 min read
↗
Programming Fundamentals

PHP syntax: Difference between parsing and behavior

Bir programın sözdizimsel olarak geçerli olması beklenen işi yaptığı anlamına gelmez. Noktalı virgül ifadeyi, süslü parantez bloğu

2 min read
↗
Programming Fundamentals

PHP output operations: echo, print and HTML context

echo ve print çıktı akışına metin aktarır. Kullanıcı metni HTML içinde gösteriliyorsa hangi çıktı fonksiyonunun seçildiğinden önce

2 min read
↗
Programming Fundamentals

PHP comments: Documenting the rationale for the decision

İyi yorum kodun ne yaptığını tekrar etmez; neden bu yolun seçildiğini, hangi koşulun korunacağını ve değişikliğin sınırlarını açık

2 min read
↗
Programming Fundamentals

PHP variables: Type and trust source

Değişken bir değere verilen addır. PHP'nin dinamik türleri esneklik sağlar; dış girdinin beklenen türde ve aralıkta olduğunu varsa

2 min read
↗
Programming Fundamentals

PHP operators: Explicit comparison and precedence

Operatörler değerleri karşılaştırır, dönüştürür veya birleştirir. Kimlik ve rol gibi güvenlik kararlarında örtük tür dönüşümünün b

2 min read
↗
Programming Fundamentals

PHP Data Types: Type Inspection and Input Contracts

42 ve "42" ekranda aynı görünebilir ama farklı türlerdir. Türü gözlemlemek tanılamaya yarar; değerin iş kuralına uygun olduğunu ay

2 min read
↗
Programming Fundamentals

PHP string operations: UTF-8 and character count

Metin işlerken bayt uzunluğu ile karakter sayısı aynı olmayabilir. Türkçe karakterler içeren bir uygulamada kodlama sözleşmesinin

2 min read
↗
Programming Fundamentals

PHP constants: Naming the business rule

Sabit, çalışma sırasında yeniden atanması beklenmeyen değeri adlandırır. Bir değerin const ile tanımlanması onu gizli veya erişile

2 min read
↗
Programming Fundamentals

PHP conditions: From decision table to safe flow

if ve elseif bir uygulamanın hangi durumda hangi yolu izleyeceğini belirler. Güvenlik kararı yalnızca başarılı dalı değil, reddedi

2 min read
↗
Programming Fundamentals

PHP switch: State matching and controlled exit

switch tek bir değeri birden fazla durumla karşılaştırır. break unutulduğunda eşleşen daldan sonraki işlemler de yürüyebilir; bu d

2 min read
↗
Programming Fundamentals

PHP loops: Termination and resource limits

Döngü bir işlemi tekrarlarken her adımın sonlanma koşuluna nasıl yaklaştığını açıkça görmek gerekir. Web isteğinde doğru sonuç kad

2 min read
↗
Programming Fundamentals

PHP Arrays: Record Contracts and Missing Fields

PHP array yapısı hem sıralı listeyi hem anahtar-değer kaydını temsil edebilir. Aynı türde olmaları, bu iki veri biçiminin aynı söz

2 min read
↗
Programming Fundamentals

PHP superglobals: Validating request source

$_GET, $_POST ve $_COOKIE farklı giriş kanallarıdır. Bu değişkenlerin hazır bulunması, içlerindeki değerlerin türünün veya güvenil

2 min read
↗
Programming Fundamentals

PHP sessions: From cookie to identity lifecycle

Çerez tarayıcıda saklanan veridir; oturum genellikle sunucudaki duruma bir kimlikle erişir. Oturum kimliğinin korunması ve yenilen

2 min read
↗
Programming Fundamentals

PHP forms: Validation, CSRF and response

Tarayıcıdaki required veya JavaScript kontrolü sunucuya yalnızca doğru veri geleceğini garanti etmez. Sunucu alanın biçimini, kull

2 min read
↗

Bir adım daha ilerlediniz.

Dersi bitirdiyseniz tamamlandı olarak işaretleyin. İlerlemeniz bu cihazda saklanır.

Academy menu

Akademide ara

En az 2 karakter yazın.