PHP 5 Syntax

Hello Guys In This Post We will Learn about PHP 5 Syntax ,  We will leran about PHP 5 Syntax with help of php and mysql, do you want to learn this if yes then let's get started.

PHP 5 Syntax

Basically php syntax  can write anwhere in php file start with <?php and end with ?>

<?php
// PHP code goes here
?>

First Web page with PHP

Friends We will create first web page in php with help of notepad++ and write code given following

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
echo "Hello World!";
?>

</body>
</html>

We use echo to print the message

Note: Every PHP statements end with a semicolon (;) like as 

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
echo "Hello World!";

echo "Hello Student!";
?>

</body>
</html>

 

What to do right now ?

We will learn about PHP Comments so let's get started.

PHP Comments

We use php comments for unused code or code indication and commented code will not show on your web Browser.

there are several ways to comment in this So let's know about them.

PHP comment By forward slash  ( / ) For Single line

Friends we can comment any line of PHP code use of double forward slash ( / /), as given following example 

 

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
//echo "Hello World!";

echo "Hello Student!";
?>

</body>
</html>

PHP comment By Hash  ( #) For Single line

Friends we can comment any line of PHP code use of Hash (#), as given following example 

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
#echo "Hello World!";

echo "Hello Student!";
?>

</body>
</html>

PHP comment By forward slash  ( / ) and star ( *) For Single line

Friends we can comment single and multiple line of PHP code use of  forward slash  and star ( /*....*/) , as given following example 

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
/*echo "Hello World!";

echo "Hello Student!";

*/

?>

</body>
</html>