Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

PHP Syntax

Fri Sep 05, 2008 1:18 am

The php semantic is close to other programming languages like (C/PERL ...) .PHP script code must be between the <? ?> or <?php ?> brackets.

Code:

<?php
 
#php code here 
 
?> 
 html code here like any html page

<? 
 
#php code here 
?>
 


'#' is for comments


Hello world php

You can include your php code within the html tags

Code:
<html>
<head>
<title>Hello world php</title>
</head>
<body>
<?php
echo "Hello World!";
?>
</body>
</html>


the output of this is

Code:
Hello World!


Semicolon
In the above example you may be see that the php line is ends with semicolon ';' .
for example again
Code:
<html>
<head>
<title>Hello world php</title>
</head>
<body>
<?php
echo 
"Hello World! ";
echo "Hello World! ";
echo "Hello World! ";
echo "Hello World! ";
echo "Hello World! ";
?>
</body>
</html>


the output is :
Code:
Hello World! Hello World! Hello World! Hello World! Hello World!



White Space

whitespace is ignored between PHP statements
Code:
<html>
<head>
<title>Hello world php</title>
</head>
<body>
<?php
echo 
"Hello World!"
 



echo "Hello World!";
?>
</body>
</html>

the output is :
Code:
Hello World!Hello World!




Post a reply
  Related Posts  to : PHP Syntax
 syntax of the session_start () in php     -  
 java Collection Syntax     -  
 AJAX SYNTAX ERROR IE     -  
 compiler code of syntax analyzer in C++     -  
 correct syntax for access providers in java     -  

Topic Tags

PHP Basics