-
Notifications
You must be signed in to change notification settings - Fork 1
/
basics.php
82 lines (81 loc) · 1.69 KB
/
basics.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
$movie = "Star Wars";
$which = 1;
$movies = array("Alien", "Aliens","More Aliens");
$one = 1;
$two = 'k';
print_r($_SERVER["REQUEST_METHOD"]);
?>
<!DOCTYPE html>
<html>
<head>
<title>Basics</title>
</head>
<body>
<h1>Basics</h1>
<p> <?php echo "I like $movie $which"; ?> </p>
<p><?php echo implode(',', $movies);?></p>
<p> <?php echo htmlspecialchars("<script>This is my bad script</script>"); ?> </p>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST">
<input type="hidden" name="bob" value="priceless">
<button type="submit">Send it</button>
</form>
<?php
if(!empty($two)){
echo "I am not empty";
}
?>
<h3>SUPER GLOBALS</h3>
<ul>
<li>POST</li>
<li>GET</li>
<li>SERVER (to get PHP_SELF and REQUEST_METHOD)</li>
</ul>
<h3>New html</h3>
<ul>
<li><pre></li>
</ul>
<h3>CSS</h3>
<ul>
<li>transform</li>
<li>transition</li>
</ul>
<h3>Methods to know</h3>
<ul>
<li>echo</li>
<li>print_r()</li>
<li>explode()</li>
<li>array_splice()</li>
<li>count()</li>
<li style="color:magenta">*implode()</li>
<li>fopen()</li>
<li>fread()</li>
<li>fwrite()</li>
<li>fclose()</li>
<li>file_get_contents()</li>
<li>file_put_contents()</li>
<li>str_getcsv()</li>
<li>isset()</li>
<li style="magenta">* empty()</li>
<!--<li></li> -->
</ul>
<h3>Techniques</h3>
<ul>
<li>foreach</li>
<li>retrieveing data from a form</li>
<li>self-referencing file - form submitted
<ul>
<li>check if hidden input isset()</li>
<li>check if $_SERVER["REQUEST_METHOD"] is post</li>
<li>if (isset($_POST['myval'] && $_SERVER["REQUEST_METHOD"] == "POST"){}</li>
</ul>
</li>
<li>if
<ul>
<li>compound if statements</li>
</ul>
</li>
<li>concatenation (concat. operator is <code>.</code>)</li>
</ul>
</body>
</html>