-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPHP_06_script_variables.php
More file actions
48 lines (45 loc) · 1.29 KB
/
Copy pathPHP_06_script_variables.php
File metadata and controls
48 lines (45 loc) · 1.29 KB
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
41
42
43
44
45
46
47
48
<html>
<head>
<title>PHP Variables, Pauline Tutorial</title>
<body>
<?php
# PHP Local Variables
$x = 4;
function assignx () {
$x = 0;
print "\$x inside function is $x.
";
}
assignx();
print "\$x outside of function is $x.
";
# PHP Function Parameters
// multiply a value by 10 and return it to the caller
function multiply ($value) {
$value = $value * 10;
return $value;
}
$retval = multiply (10);
Print "Return value is $retval\n";
# PHP Global Variables
$somevar = 15;
function addit() {
GLOBAL $somevar;
$somevar++;
print "Somevar is $somevar";
}
addit();
# PHP Static Variables
function keep_track() {
STATIC $count = 0;
$count++;
print $count;
print "
";
}
keep_track();
keep_track();
keep_track();
?>
</body>
</html>