-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimplescripts.php
75 lines (64 loc) · 1.67 KB
/
simplescripts.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>this is a php page</h1>
<pre>
<?php
echo "Hello World! \n"; // outputs welcome message
$a = "yazhini";
echo "i'm " . $a . "\n";
echo "length of a is:" . strlen($a) . "\n";
echo "word count of a string is:" . str_word_count("function counts the number of words in a string") . "\n";
$x = 25;
$y = 18;
echo "x+y= " . $x + $y . "\n";
echo "<h3> replace string</h3>";
$m = "Hello World!";
echo $m . "\n";
echo str_replace("World", "yazhini", $m);
echo "<h3>string slice</h3>";
echo substr($m, 6, 5);
echo "<h3>difference b/w single and double quotes</h3>";
$p = "yazh";
echo "Hello $p \n";
echo 'Hello $p';
echo "<h3> returns datatype</h3>";
var_dump(10); //returns datatype
var_dump($x);
var_dump("yazhini");
var_dump(1.23);
var_dump(true);
var_dump([2, 3, 56]);
var_dump(NULL);
echo "<h3>scope</h3>";
function add()
{
$z = 30; //local
global $w; //global
$w = 12;
echo "w+z=" . $w + $z . "\n";
}
add();
echo "w=" . $w . "\n";
echo "<h3>class and object</h3>";
class IT
{
public $student;
public $marks;
public function __construct($student, $marks)
{
$this->student = $student;
$this->marks = $marks;
echo "My name is " . $this->student . "\n my mark is:" . $this->marks;
}
}
$IT = new IT("yazhini", 95);
?>
</pre>
</body>
</html>