Variable in PHP


Variable in PHP  are like other programming, which are used for storing value in program.

Like other programing language, we don't have to defined data type of the variable.

For example, You can Defined string, Number etc in the variable. Just you have to write like below:

$myvar1 = "This is a sentence";
$myvar2 = 23;    OR   $myvar2 = "23";   OR   $myvar2 = '23';
$myvar3 = 2.5;   OR   $myvar3 = "2.5";  OR   $myvar3 = '2.5';

For display the above value use echo/ print function.

<?php echo $myvar1;   ?>

################################################
PHP Code
################################################
<html>
<head>
<title>Variable in PHP</title>
</head>

<body>
<?php

/*
variable is case sensative
variable start with a $ sign
followed by letters or underscore
they can contain letters, numbers, underscores or dashes
no spaces
they are case-sensitive
*/

$my_var = 10;
                        $_var="Its a variane";
$my_var_string ="Hello World!";
$My_Var_String="Hello World again!";
echo $my_var;
echo "<br/>";
echo $my_var_string;
echo "<br/>";
echo $My_Var_String;

?>
</body>

</html>

Comments

Popular posts from this blog

Page Unload Show Notification to user

Function Oriented File Upload PHP

Upload File Using PHP - Example For Image