This section describes the PHP script source code file format - A text file with PHP code segments mixed into non-PHP text. The most common way to mix PHP codes is to use the PHP processing tag '?php'.
Like any other scripting language, PHP is used to transform text information from an input
to an output by mixing PHP code segments in the input text. This input of mixed PHP code and
non-PHP text is called PHP script source code, which is usually stored as a text file.
Since multiple PHP code segments can be mixed with non-PHP text, a PHP script source code
will look like this:
text PHP_code text PHP_code text PHP_code ...
When you ask the PHP to process a PHP script source code, it will separate PHP code segments
from the non-PHP text using following 3 default rules:
1. PHP processing tag: <?php PHP_code ?> - Everything included in the "php" tag will be processed as PHP code.
For example:
3. HTML "script" tag: <script language="php">PHP_code</script> - Everything between the
"script" starting tag and the "script" ending tag will be processed as PHP code. For example:
The PHP processing tag is the most commonly used way to mixed PHP codes into non-PHP text to create a PHP script source code file.
Since most PHP scripts are designed to generate Web pages, non-PHP text in a PHP script source code is made of mostly HTML tags.
Here is an example of a PHP script source code that generates a simple Web page: