Php – Syntax Overview


[rps-include post=6522]

Extension

Php source or code files generally ends with .php but generally the extension is not important. Following extensions can be used too.

  • php4
  • php5
  • php7

Php Tags

Web based programming languages generally uses tags in order to surround related code. Php is web based programming language too and uses <?php ... ?> tags. Second tag is not compulsory if the code ends without different language but makes the code more elegant .

Below we can see new code here.

<?php

echo "Hi";

?>

Semicolons

Php is C and C++ centric language and uses semicolons to specify end of statement. Each semicolon end the line or statement like below.

echo "This is a line";

echo "This is a line too";

There is another usage of semicolons too. We can use multiple semicolons for multiple statements like below.

echo "This is a line"; echo "This is a line too";

Comments

While developing applications we generally need to take notes on code or insert some explanation about the code. We call these explanation comment. comments do not have any effect on application run time.

// This is a comment
echo "This is a line"; //This is a comment to

We can also specify comments after end of the statement like the second example

Multiline Comments

Sometimes single line comments are not enough. We can specify multi line comments with /* and */ like below.

/*

This is a multiline

comment

*/

echo "hi";

Embed Into Html

Php code can be embedded into Html code easily. In the server side first the php code is executed and the result is put into related position. Below a code is embedded into html.

<html>
<body>

<?php
echo "Hi poftut.com";
?>

</body>
</html>

Case Sensitivity

Php is case sensitive programming language. Case sensitive simply means the same word with uppercase and lowercase are interpreted as different. For example cat is not the same as CAT or Cat . All of them are different.

LEARN MORE  How To Install LAMP Stack On Linux, Ubuntu, Debian,Mint,Fedora

[rps-include post=6522]

2 thoughts on “Php – Syntax Overview”

Leave a Comment