Php Basic Syntax
All php script should start with <?php and ends with ?> , On Servers that have shorthand support enabled you can also use <? and ?> .
Now most of the servers have shorthand support, Please check with your hosting provider before you use shorthand Php syntax.
Php Files
All php script files should ends with .php extension ,
PHP Echo and Print:
To output any data to the user there are two commands that can be used
echo & print .
examples :
echo "Hello world";
print "Hello World":
It outputs the same way but echo is the most commonly used by developers.
Semicolon (;) :
In Php after every statement there was a semicolon that signifies the end of that statement and that should be forgetten.
In php you can use both html and php codes in the same .php file extensions.
for example
<div> Hello World </div>
<? echo "<div>Hello world</div>";?>
While the first statement is simple html code and outside php syntax it is not handled by php parser but the next statement which is inside php syntax is handled by php parser but both can be placed in the same php files.Most of the time you will see php embedded in HTML documents
Adding Comments in your php code
To add one line of comment use (//) double slashes and for multiple lines of comments use /* (starting) and */ at the end of the line
Example :
<?php
/*
This is multiple line comment
This is multiple line comment
This is multiple line comment
This is multiple line comment
*/
//This is single line comment
?>
?>
All php script should start with <?php and ends with ?> , On Servers that have shorthand support enabled you can also use <? and ?> .
Now most of the servers have shorthand support, Please check with your hosting provider before you use shorthand Php syntax.
Php Files
All php script files should ends with .php extension ,
PHP Echo and Print:
To output any data to the user there are two commands that can be used
echo & print .
examples :
echo "Hello world";
print "Hello World":
It outputs the same way but echo is the most commonly used by developers.
Semicolon (;) :
In Php after every statement there was a semicolon that signifies the end of that statement and that should be forgetten.
In php you can use both html and php codes in the same .php file extensions.
for example
<div> Hello World </div>
<? echo "<div>Hello world</div>";?>
While the first statement is simple html code and outside php syntax it is not handled by php parser but the next statement which is inside php syntax is handled by php parser but both can be placed in the same php files.Most of the time you will see php embedded in HTML documents
Adding Comments in your php code
To add one line of comment use (//) double slashes and for multiple lines of comments use /* (starting) and */ at the end of the line
Example :
<?php
/*
This is multiple line comment
This is multiple line comment
This is multiple line comment
This is multiple line comment
*/
//This is single line comment
?>
?>
Comments
Sam - I really like this tutorial , when you are going to post your next post
Thanks
Sam
Page : 1
Page : 1
Related Topics
Random Topics
- Find Printable Tattoo Designs Online
- PageBump.com - Adsense Revenue Share Site
- What To Check When Deciding On A WebHost
- Ingredient List for Thai Green Curry
- Introduction To Muay Thai Boxing
- Essential Tips On Pouring Your Shed Foundation
- A Guide to Locating the Best Tribal Tattoo Designs
- File Upload Using Php
- InfoBarrel
- Wildcard Subdomain Facility
