PHP Syntax
PHP (Hypertext Preprocessor) code starts with <?php
and ends with ?>
. Every PHP statement ends with a semicolon ;
.
Example
<?php
echo "Hello, world!";
?>
Comments in PHP
Comments are used to explain code and are ignored by the PHP engine. You can use:
//
for single-line comments/* ... */
for multi-line comments
Example
<?php
// This is a single-line comment
/*
This is a
multi-line comment
*/
echo "Welcome to PHP!";
?>
Case Sensitivity
Function names are not case-sensitive, but variables are:
Example
<?php
ECHO "Hello";
echo "World";
$msg = "Test";
echo $Msg; // Error: undefined variable
?>