-
Notifications
You must be signed in to change notification settings - Fork 0
/
superGlobals.php
43 lines (36 loc) · 1.26 KB
/
superGlobals.php
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
<!DOCTYPE html>
<html>
<body>
<h1>My First PHP page</h1>
<form action = "<?php echo $_SERVER['PHP_SELF'];?>" method="post">
Name : <input type = "text" name = "fName" id = "fname" />
<input type="submit" />
</form>
<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['fName'];
if(empty($name)) {
echo "<p>Name is empty</p>";
} else {
echo "<p>" . $name . "</p>";
}
}
echo "<p>" . $_SERVER['PHP_SELF'] ."</p>";
echo "<p>" . $_SERVER['SERVER_NAME'] ."</p>";
echo "<p>" . $_SERVER['HTTP_HOST'] ."</p>";
echo "<p>" . $_SERVER['HTTP_REFERER'] ."</p>";
echo "<p>" . $_SERVER['HTTP_USER_AGENT'] ."</p>";
echo "<p>" . $_SERVER['SCRIPT_NAME'] ."</p>";
echo "<p>" . $_SERVER['GATEWAY_INTERFACE'] ."</p>";
echo "<p>" . $_SERVER['SERVER_ADMIN'] ."</p>";
echo "<p>" . $_SERVER['SERVER_PORT'] ."</p>";
$x = 25;
$y = 6;
function add() {
$GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];
}
add();
echo "$z<br>";
?>
</body>
</html>