When parsing a file, PHP looks at the opening and closing tags to decide which sections to process.

You can see PHP opening and closing tags in the example below.

<?php // PHP kodları buraya yazılır ?>

There is also a short version of the PHP opening tag: PHP short open tags are as follows: <? ?>. PHP codes are written between these tags.

<? // PHP kodları buraya yazılır ?>

PHP File Extension

PHP file extension: .php. The extension of a PHP file must be .php. However, PHP codes can be run within the HTML file. HTML codes can also be run within the PHP file.

PHP Hello World

In this example, we will print Hello World with PHP. Semicolon ';' at end of line Let's pay attention to its use. In PHP, every expression is separated by a semicolon ';' It ends with . If you forget to add a semicolon at the end of the statement, PHP will return a Parse Error level error and the codes will not work. However, if there is no other statement or code at the end of the statement, the script will run even if a semicolon is not used. The first example will work, the second example will not work and will return an error at parse error level.

// 1. Örnek
echo 'Hello World';
// 2. Örnek
echo 'Hello World';
echo 'Hello World 2';

PHP Case Sensitivity

In PHP, keywords (for example: if, else, while, echo, etc.), classes, functions and user-defined functions are not case sensitive. However, it is recommended to always use lowercase letters to improve readability.

Tip: In PHP, all variable names are case sensitive. In the example below, only the first statement prints the data of the $color variable. This is because $color, $COLOR and $coLOR are treated as three different variables by PHP.

$color = 'mavi';
echo 'Arabamın rengi: ' . $color . '
'; // Çıktı: Arabamın rengi: mavi
echo 'Odamın rengi: ' . $COLOR . '
'; // Çıktı: Odamın rengi:
echo 'Telefonumun rengi: ' . $coLOR . '
'; // Çıktı: Telefonumun rengi: