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.
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
| Status | Recommended approach | Why? |
|---|---|---|
| CLI call | text appeared | Does not require HTTP session |
| web form | Type and authorization check | Client data is not reliable |
| HTML response | Output encoding | Prevents 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.
- Write down the expected outcome and acceptance condition before the action.
- Change a single variable; Record the observation and the medium you used.
- 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
- C++: Value, lifetime and resource management
- XAMPP: Isolated development environment
- VS Code: Reproducible workspace
- PHP files: Entry point and responsibility
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.
