Php – Syntax Overview
Php source or code files generally ends with
.php but generally the extension is not important. Following extensions can be used too.
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 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";
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
Sometimes single line comments are not enough. We can specify multi line comments with
*/ like below.
This is a multiline
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.
echo "Hi poftut.com";
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 . All of them are different.