-
Notifications
You must be signed in to change notification settings - Fork 0
/
adarshsite.php
186 lines (150 loc) · 4.62 KB
/
adarshsite.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Adarsh website</title>
</head>
<body>
<!-- Including HTML Files -->
<!-- <?php include "Header.html" ?>
<p>Hello I am Adarsh Vajpayee.</p>
<?php include "footer.html" ?> -->
<!-- Including PHP files -->
<!-- <?php
$title = "My First Php Post";
$author = "Adarsh";
$wordCount = 100;
include "article-header.php"
?> -->
<!-- Including useful tools files -->
<!-- <?php
include "useful-tools.php";
echo "$FeetInMiles<br>";
get_name("ADARSH BHAI");
?> -->
<!-- Classes And Objects In Php -->
<!-- creating Custom Datatype :-->
<!-- lets say we are writing piece of software for library. -->
<!-- <?php
class Book{
var $title;
var $author;
var $no_of_pages;
function __construct($aTitle,$aAuthor,$aPages)
{
$this->title = $aTitle;
$this->author = $aAuthor;
$this->pages = $aPages;
}
}
$book1 = new Book("Harry Potter","JK Rowling",400);
// $book1->title = "Harry Potter";
// $book1->author = "JK Rowling";
// $book1->no_of_pages = 400;
$book2 = new Book("Lord of The Rings","Tolkien",700);
// $book2->title = "Lord of the Rings";
// $book2->author = "Tolkien";
// $book2->no_of_pages = 700;
// echo $book1->title;
// echo $book2->title;
echo $book1->title;
?> -->
<!-- OBJECT FUNCTIONS -->
<!-- <?php
class student{
var $name;
var $major;
var $gpa;
function __construct($name,$major,$gpa)
{
$this->name = $name;
$this->major = $major;
$this->gpa = $gpa;
}
function hasHonors(){
if($this->gpa >= 8.5)
{
return "true";
}
return "false";
}
}
$student1 =new student("Adarsh","Information Science",7.2);
$student2 =new student("Gopal","Information Science",9.2);
echo $student1->hasHonors();
echo $student2->hasHonors();
?> -->
<!-- Getters And Setters -->
<!-- <?php
class Movie{
public $title;
// public $rating;
private $rating;
function __construct($title,$rating)
{
$this->title = $title;
$this->setRating($rating);
}
function getRating()
{
return $this->rating;
}
function setRating($rating)
{
if($rating == 'G' || $rating == 'PG' || $rating == 'PG-13' || $rating == 'R'|| $rating == 'NR')
{
$this->rating = $rating;
}
else
{
$this->rating = "NR";
}
}
}
$avengers = new Movie("Avengers", "Dog");
//G, PG, PG-13, R, NR.....(Ratings).
// $avengers->rating = "Dog"; It is In appropite giving Dog as rating so to avoid this we make it private instead of public.
echo $avengers->getRating();
?> -->
<!-- Inheritance In Php -->
<?php
class chef{
function makeChicken()
{
echo "The Chef make Chicken<br>";
}
function makeSalad()
{
echo "The Chef make Salad<br>";
}
function makeSpecialDish()
{
echo "The Chef make BBQ Chicken<br>";
}
}
class ItalianChef extends chef
{
function makePasta()
{
echo "The Italian chef makes a Pasta<br>";
}
function makeSpecialDish()
{
echo "The Italian chef makes Chicken Biryani";
}
}
$chef = new chef();
$chef->makeChicken();
$chef->makeSpecialDish();
$ItalianChef = new ItalianChef();
$ItalianChef->makeChicken();
$ItalianChef->makePasta();
//Lets Say Italian Doesn't want to make Special Dish Similar to chef.
//He wants to make his own special Dish.
// Nothing But Overiding
$ItalianChef->makeSpecialDish();
?>
</body>
</html>