Easy php syntax:
A php syntax can be placed anywhere in the code document.A php code First start : <?php
End of code : ?>
Example:
<?php//PHP code here
?>
A php file extension is .php
You can normally save this file (your choice name).php such as index.php
Now we can an example:
<!DOCTYPE html><html>
<body>
<h2>My first php code</h2>
<?php
echo "First experience of php language!";
?>
</body>
</html>
Now you can save this file index.php or your choice name.next run this file in your compiler.
Output: First experience of php language!
Comments in php:
A comments is very important in any language.A comment in php may in a single line or other system.Now see some example for php comment . <!DOCTYPE html>
<body>
<h2>My first php code</h2>
<?php
//Here is single line comment
#Also single line comment
/*Here is multiple line comment in php
that execute whole code in comment block*/
echo "First experience of php language!";
?>
</body>
</html>
PHP Case Sensitivity:
All keywords of php language is not case sensitive.such as if,else,else if,switch,case,echo etc. and user-defined functions is not case sensitive.Now we see this example to clear concept:
<!DOCTYPE html>
<html>
<body>
<h2>My first php code</h2>
<?php
ECHO"This is first language practise.";
echo "This is first language."
EcHo "This is first language.";
?>
</body>
</html>
PHP Variable:
In php language,a variable starts with the $ sign,then name of the variable.
Now see an example:
<?php
$text = "Hellow World";
$m = 5;
$n = 10.25;
?>
In php language type is not important.Here just assign $ sing and type a name.that's ok.you can assign any type of variable such as integer,float,double and string.
No comments:
Post a Comment