-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathbasic.php
82 lines (60 loc) · 1.44 KB
/
basic.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
// echo "Hello World!";
// echo "<br>";
// print "Hello World!";
// print "<br>";
//echo is slightly faster
//PHP is a loosely typed language
// $a = 15;
// echo $a;
// echo "<br>";
// $a = 1.798;
// echo $a;
// echo "<br>";
// $a = "Raizu";
// echo $a;
// echo "<br>";
// $ans = 42;
// echo "The answer is ".$ans."<br>";
// echo "The answer is $ans <br>";
// $p = 4;
// $q = 7.5;
// echo $p+$q;
// echo "<br>";
//var dump
// var_dump($p);
// echo "<br>";
// var_dump($q);
// echo "<br>";
//operators
// echo $p-$q."<br>";
// echo $p*$q."<br>";
// echo $p/$q."<br>";
//functions
// function temp($a, $b) {
// return $a**$b;
// }
// echo temp(2,4)."<br>";
//default args
// function fun($b=3) {
// return 2**$b;
// }
// echo fun(7)."<br>";
// echo fun()."<br>";
// $arr = array(2,1,"omega");
// for($i=0;$i<3;$i++) {
// echo $arr[$i]." ";
// }
// echo "<br>";
// $assoc = array("age" => 12, "name" => "Raizu");
// echo $assoc["age"]." ".$assoc["name"]."<br>";
// foreach ($assoc as $key => $value) {
// echo "Key is $key and value is $value<br>";
// }
// $test = array(7,6,5);
// sort($test);
// for($i=0;$i<count($test);$i++)
// echo $test[$i]." ";
// echo "<br>";
//Several predefined variables in PHP are "superglobals", which means that they are always accessible, regardless of scope - and you can access them from any function, class or file without having to do anything special.
?>