+91 9952732367

PHP code Syntax and Structure

  • PHP code is interpreted by a web server with a PHP Preprocessor module which generates the resulting HTML.
  • The client browser only receives HTML.

Basic Structure:

  • PHP script always starts with <?php and ends with ?>.
  • PHP script can be placed anywhere in the document.
  • In some server you can use the above script as <? and ends with ?> but it does not support by all servers.
  • Normally PHP file contains HTML tags and PHP scripts.
  • PHP file must be stored in .php file extension
  • Each PHP code must end with semicolon(;)

Sample PHP coding


<html>

<head><title>Sample PHP</title></head>

<body>

<?php echo "I am learning PHP from s3learn.com"; ?>

</body>

</html>

Data Received by the Browser:


<html>

<head><title>Sample PHP</title></head>

<body>

I am learning PHP from s3learn.com

</body>

</html>

Comments in PHP

  • // for single line comments.
  • /* some text  block */ for comment block.

<html>
<body>

<?php
//This is single line comment

/*
This is multi line
comment block
*/
?>

</body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

About the Author:

Selvakumar Sankaravel
Hai I am Software and web developer. I studied B.Sc(Maths) in Ayya Nadar Janaki Ammal College,India and I studied MCA in Kalasalingam University,India. Now I am working as a Developer cum Project Leader at Kalasalingam University and I am doing freelancer works too.
Copyright © s3learn.com