PHP has lots many things to do, you can explore the many thing in PHP for your web development. PHP
To learn PHP, we have to understand some basics behind the PHP.
That it, how to write PHP? How to make comment? I.e. To hide from complier and readable in program pan, Variable declaration, syntax, operators etc.,
Let’s see how to make a comment.
Comment in PHP
Comment using * asterisk mark
Comment using double foreword slash // & hash # sign, comment using this sign called as single line comment
<!DOCTYPE html>
<html>
<body>
<?php
<body>
<?php
/*
Use of forward slash with asterisk mark is Multi-line comment. You can use if your to add for your program description or whenever is necessary, all the comments or code written inside the comment will not be complied by php compiler.
*/
// Here, I am using double forward slash; this is a single line comment.
# Here, I am using only hash sign, this is also a single line comment.
# Here, I am using only hash sign, this is also a single line comment.
?>
</body>
</html>
</body>
</html>
Variable declaration in PHP
PHP has its own unique style to declare variable. PHP is uses “Doller” Sign ($) to declare any variable. User this $ sign as prefix to every alphanumeric character.
Sample code:
<!DOCTYPE html>
<html>
<body>
<?php
<html>
<body>
<?php
$a=10; // Variable $a is declared and value 10 is assigned to it
$b=20; // Numeric variable $b as declared
$c=null; // Variable declared $c as null, null is assigned to variable $c
?>
</body>
</html>
</body>
</html>
Is variable case sensitive in PHP? Yes
Is variable case sensitive in PHP? Yes, it’s true; variables are case sensitive in PHP.
You can create same name variables by changing its case.
Sample Code:A
<! DOCTYPE html>
<html>
<body>
<?php
$x=10;
$X=20;
$y=$x+$X;
echo $y;
?>
</body>
</html>
Output:
30
<! DOCTYPE html>
<html>
<body>
<?php
$x=10;
$x=20;
$y=$x+$x;
echo $y;
?>
</body>
</html>
Output:
40