Wednesday 10 March 2021

Php: Basic syntax

a. Php code should be written in between <?php and ?> statements.

 

Syntax

<?php



?>

 

b. Every line in php ends with a semicolon.

<?php

	echo "Hello World!!!";

?>

 

c. Variables should start with $ symbol.

$str = "Hello Dear, How are you";

 

d. Everything in Php is function based.

print_r (explode(" ",$str));

 

syntax_demo.php

#!/usr/bin/php

<?php

	echo "Hello World!!!\n";

	$str = "Hello Dear, How are you";

	print_r (explode(" ",$str));

?>

 

Output

$./syntax_demo.php 

Hello World!!!
Array
(
    [0] => Hello
    [1] => Dear,
    [2] => How
    [3] => are
    [4] => you
)

 

 

 

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment