Any where we can use PHP script inside of the document.
The PHP script start with <?php and ends with ?>
<?php // PHP code goes here ?>
The default file extension is .php ( Eg. test.php )
Example :
To get a fell of PHP code, first we will start with simple PHP script. Since “Hello, World!” is an essential example, first we will create a friendly little “Hello, World!” script.
<html>
<head>
<title>Hello World</title>
<body>
<?php echo "Hello, World!";?>
</body>
</html>
It will produce the following output
Hello, World!
Note: PHP statements are terminated by semicolon ( ; )
Comments in PHP:
A comment in PHP code is a line, that is not execute or read by program. Below we mentioned the different types of comments in PHP.
<?php
// Single line comment
# single line comment
/*
Multiple line comment
*/
?>
Case-insensitive in PHP:
In PHP, all user defined function, classes and keywords ( Eg: print, echo, foreach, while, etc., ) are case-insensitive.
<?php
print("test");
PrInt("test");
PRINT("test");
?>
Output:
test
test
test