PHP Syntax

PHP Syntax

PHP Opening and Closing Tags

When we embed PHP in HTML, the most commonly open PHP tags.
Starting PHP Tags.

<?php

Closing PHP Tags.

?>

Note :
Whenever a PHP code is required to be written, using Starting PHP and Closing PHP tags will be required.

Full Example
<?php
// Write the PHP code here.
?>

Remember :
Use semi-colon(;) to finish each PHP line.
But not use semicolon in comments.

Example
<?php

echo "Hello world!";
echo "My First Word";
echo "https://itcollegeall.blogspot.com";

?>

Comments

PHP has three forms of comments

  • Single-line comments begin with a double slash (//).
  • Single-line comments begin with a Number (#).
  • Multi-line comments begin with "/*" and end with "*/".
Single-line comments with a double slash
Single-line comments with Number

Example
<?php

// Single line comment with a double slash (//)
# Single line comment with a Number (#)

?>

Multi-line comments start with "/*" and end with "*/"

Example
<?php

/*
Multiple comments line no.1
Multiple comments line no.2
Multiple comments line no.3
Multiple comments line no.4
*/

?>

Share This:

No comments:

Post a Comment

Advertiser
Counter
Flag Counter