PHP - Create and
Execute Variables
To create and execute a PHP Variables Example
program
1. Start Xampp server (Apache)
2. Goto virtual path folder (C:\xampp\htdocs)
3. Create Variable.php file and type the program
4. Execute the program on your Web browser using by
this URL link (http://localhost/ Variable.php)
<html>
<body>
<?php
$a = 25; // Numerical variable
$b = “Hello”; // String variable
$c = 5.7; // Float variable
echo ‚Number is : “.$a.‚<br/>”;
echo ‚String is : “.$b.‚<br/>”;
echo “Float value : “.$c;
$txt = “INDIA”;
echo “I love $txt!”;
$x = 2;
$y = 2;
echo $x + $y;
function demo() {
echo «<p>Variable x inside
function is: $x</p>»;
}
demo();
echo “<p>Variable x outside
function is: $x</p>”;
function myTest() {
static $a = 0;
echo $a;
$a++;
}
myTest();
echo “<br>”;
myTest();
echo “<br>”;
myTest();
?>
</body>
<html>
Number is : 25
String is : Hello
Float value : 5.7
I LOVE INDIA
4
0
1
2
Variable x inside function is:
Variable x outside function is: 2
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.