Post Page Advertisement [Top]



Click here to send WhatsApp On Unsaved Mobile Numbers For Free

PHP Syntax with examples || PHP Tutorial 2



PHP Syntax with examples



A PHP code only runs on a server. While running the PHP code on the server, it will return a plain HTML result on your web browser.

PHP Basic Syntax


<?php
     //your code here;
?>

  • PHP syntax starts with <?php and end with ?>
  • All php codes are terminate with semicolon i.e, (;)
  • The extension of PHP file is ".php"
  • PHP files contains PHP scripts, plain text, HTML tags, CSS as well as JavaScript.

Example:

<!DOCTYPE html>
<html>
<body>

<h1>Hello BlogLearner</h1>

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

</body>
</html>

Output:

Hello BlogLearner


Hello World!!!


Comments Syntax in PHP


There are three ways in which we can use comments in the PHP script. All three ways are explained in the following example.

The comment is the process through which the codes or plane texts are not read at the time of execution of the code.

<!DOCTYPE html>
<html>
<body>

<?php

// Double slash is used as a single-line comment in PHP

# Hash is also used as a single-line comment in PHP

/*

You can also use multi-line comment in PHP which starting with /*                                            and ending with */

*/


// This is a comment
echo "Hello World!!!";

?>

</body>
</html>

Output:

Hello World!!!


PHP is a Case Sensitivity


Example:

<!DOCTYPE html>
<html>
<body>
<?php
            $i=true;

if ($i) {
echo "BlogLearner<br>";
}

IF ($i) {
echo "BlogLearner<br>";
}

ECHO "BlogLearner<br>";
echo "BlogLearner<br>";
EcHo "BlogLearner<br>";
?>
</body>
</html>

Output:

BlogLearner
BlogLearner
BlogLearner
BlogLearner
BlogLearner


Screenshots:



PHP Syntax with examples || PHP Tutorial 2



















Output:


PHP Syntax with examples || PHP Tutorial 2












***

What is PHP? || PHP Introduction || PHP Tutorial 1



---
I hope you likable this nice post. Do not forget to share it together with your friends, the Sharing Button is below the post. Apart from this, if there's any downside within the intermediate, don't hesitate to request the Comment Box. we are going to be happy to help you.

I will continue to write more and more on this blog, so do not forget to make our blog BlogLearner as a bookmark (Ctrl + D) on your mobile or computer and subscribe to us to get all the posts in your email. Do not forget to share these posts, if you like it. You can facilitate us reach additional individuals by sharing it on social networking sites like Facebook or Twitter.


PHP Syntax with examples || PHP Tutorial 2
PHP Syntax with examples || PHP Tutorial 2


#php #php-tutorial-2 #bloglearner #rrkksinha





No comments:

Post a Comment

Bottom Ad [Post Page]

rrkksinha.