Before we talk about the syntax of PHP, let’s first define what is meant by the word syntax.
Syntax – the rules that must be followed to write properly structured code .
PHP syntax and semantics are similar to most other programming languages (C, Java, Perl). The only difference is that the PHP code is embedded in the html page layout . All PHP code must be contained in the following tags:
If you do not want problems , then write in standard form. This ensures that your scripts will work on servers with different settings.
How to save your PHP page
If you have a PHP code that is included in the HTML and you want the browser to interpret it correctly, you should save the file as .php instead of the standard .html. So make sure to check you save the files correctly. For example instead index.html you need to save page as index.php
Simple php page code
<title>My First PHP Page</title>
echo "Hello World!"
If you save the file (for example , helloworld.php) and upload it on the server with PHP and then load it in the browser , you should see «Hello World!». If you did not please check that you have done everything correctly and server supports php. Or ask questions in the comments.
We used the command echo, to write «Hello World!». We will return to this command in the following lessons.
Thank you for your attention.