Semicolon And White Space In Php

The Semicolon :

As you may or may not have noticed in the above example, there was a semicolon after the line of PHP code. The semicolon signifies the end of a PHP statement and should never be forgotten. For example, if we repeated our “Hello World!” code several times, then we would need to place a semicolon at the end of each statement.

CODE/PROGRAM/EXAMPLE
//PHP and HTML Code:
<html>
<head>
<title>My First PHP Page</title>
</head>
<body>
<?php
echo "Hello World! ";
echo "Hello World! ";
echo "Hello World! ";
echo "Hello World! ";
echo "Hello World! ";
?>
</body>
</html>

// O/P : Hello World! Hello World! Hello World! Hello World! Hello World!

White Space :

As with HTML, whitespace is ignored between PHP statements. This means it is OK to have one line of PHP code, then 20 lines of blank space before the next line of PHP code. You can also press tab to indent your code and the PHP interpreter will ignore those spaces as well.

CODE/PROGRAM/EXAMPLE
//PHP and HTML Code:
<html>
<head>
<title>My First PHP Page</title>
</head>
<body>
<?php
echo "Hello World!";
echo "Hello World!";
?>
</body>
</html>

// O/P : Hello World!Hello World!
#semicolon_and_white_space_in_php #Semicolon__in_php #White_Space_in_php

(New page will open, for Comment)

Not yet commented...