Basic PHP Syntax
A PHP script can be placed anywhere in the document.The PHP script is executed on the server, and the plain HTML result is sent back to the browser
A PHP script starts with <?php and ends with ?>
<?php // Here the PHP code goes ?>
A PHP file normally contains HTML tags, and some PHP scripting code.
Below, we have an example of a simple PHP file, with a PHP script that uses a built-in PHP function “echo” to output the text “Hello India!” on a web page:
<!DOCTYPE html> <html> <body> <h1>My first PHP page</h1> <?php echo "Hello Indian!"; ?> </body> </html>
NOTE- The default file extension for PHP files is “.php”.
PHP Case Sensitivity
In PHP, all user-defined functions, classes, echo , and keywords are NOT case-sensitive.
<!DOCTYPE html> <html> <body> <?php echo "Hello Indian!<br>"; ECHO "Hello Indian!<br>"; EcHo "Hello Indian!<br>"; ?> </body> </html>
A comment in PHP code is a line that is not read/executed as part of the program. Its only purpose is to be read by someone who is editing the code!
PHP supports three ways of commenting:
<!DOCTYPE html> <html> <body> <?php // This is a single line php comment # This is also a single line php comment /* This is a multiple lines comment in php block that spans over more than one line */ ?> </body> </html>