-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.php
More file actions
40 lines (34 loc) · 867 Bytes
/
variables.php
File metadata and controls
40 lines (34 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
$txt="Hello world";
$x=5;
$y=10.5;
$name="peter";
$age=18;
function myTest() {
$x = 5; // local scope
echo "<p>Variable x inside function is: $x</p>";
var_dump($x);
}
myTest();
function childrenNames(){
$name= "Kiddiko";
echo "my name is $name <br>";
}
childrenNames();
function printResults(){
$grade="A"; #local variable
$stdName= "Digo";
echo "Dear $stdName, your exam grade is an $grade <br>";
# echo "$txt" #$txt is a global variable and cannot be accessed in a function
#please remove the coment to test the accessibilty of this code
var_dump($grade);
}
printResults();
$cars= array("Volvo", "Range-rover", "Ford");
var_dump($cars);
echo "$txt <br>";
echo $x+$y;
echo "Hello, my name is $name, i am $age years old"
#variables scope
#GLOBAL, LOCAL, STATIC SCOPES
?>