In this part of the php tutorial we are going to learn about the basic syntex of php, As we have alrady told in our orevious post that php basic syntex starts with <?php or <? and in both case ends with ?> so if have to write any php script we have to write inside <?php ?>
now how to make a comment string in php,
to make a string commenting in php developer needs to give # (has) sign before the string or have to put // (double slash sign) before the string or to make comment any string inside a line or a part of string inside a line developer have to keep the commentable string inside /* (slash star) and */ (star slash) to make the portion commenting.
Example:
<?php # the total lign will be commented // in this case also the total lign will be commented /* In this portion the string inside slash and star will be commented*/ echo 5 /* here will be the addition */ + 4; ?>
Now How to print a line in PHP.
There is mainly two process available in PHP to print and they are echo and print. In case echo a string needs to keep inside a double quote(“”). else if you keep the string in single quote(”) then the string will be printed as it is, that is, if you keep a variable inside the string it will print the veriable as its written instade of printing its value , The value will be printed if you keep the portion in a double quote(“”). and also the echo syntex is not case sensetive, that is you can write echo in upper or lower or mixture case and it will print the string.
Example:
<?php $i = 10; print("It will print the line inside the brasses and quote if it is not a veriable"); //It will print the line inside the brasses and quote if it is not a veriable echo "The value of i = $i"; //The value of i = 10 echo 'The value of i = $i'; //The value of i = $i EcHo "Print the value";//Print the value ECHO "Print the value";//Print the value echo "Print the value";//Print the value ?>
Concatenation in PHP
To concatinate in PHP we need to use . (dot sign) and it will join two string, an example is given below regarding that.
Example:
<?php $i = 10; echo 'The value of i = ' . $i . ' and it will print the value'; //The value of i = 10 and it will print the value ?>
I hope the post PHP basic syntex helped you and you have started to write php script by yourself.
Thanks for Reading.
No comments:
Post a Comment