Function Overriding

Ultimate PHP and MySQL Web Development Object Oriented Programming
2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€93.28
List Price:  €130.60
You save:  €37.31
£77.40
List Price:  £108.37
You save:  £30.96
CA$139.10
List Price:  CA$194.74
You save:  CA$55.64
A$151.96
List Price:  A$212.75
You save:  A$60.79
S$132.54
List Price:  S$185.57
You save:  S$53.02
HK$777.34
List Price:  HK$1,088.31
You save:  HK$310.96
CHF 87.57
List Price:  CHF 122.61
You save:  CHF 35.03
NOK kr1,099.88
List Price:  NOK kr1,539.87
You save:  NOK kr439.99
DKK kr695.71
List Price:  DKK kr974.02
You save:  DKK kr278.31
NZ$169.08
List Price:  NZ$236.72
You save:  NZ$67.64
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳12,015.39
List Price:  ৳16,822.03
You save:  ৳4,806.63
₹8,438.70
List Price:  ₹11,814.51
You save:  ₹3,375.81
RM438.20
List Price:  RM613.50
You save:  RM175.30
₦168,724.46
List Price:  ₦236,221
You save:  ₦67,496.53
₨27,921.63
List Price:  ₨39,091.39
You save:  ₨11,169.76
฿3,424.75
List Price:  ฿4,794.78
You save:  ฿1,370.03
₺3,433.65
List Price:  ₺4,807.25
You save:  ₺1,373.59
B$573.73
List Price:  B$803.24
You save:  B$229.51
R1,846.20
List Price:  R2,584.75
You save:  R738.55
Лв182.39
List Price:  Лв255.35
You save:  Лв72.96
₩139,806.01
List Price:  ₩195,734.01
You save:  ₩55,928
₪375.45
List Price:  ₪525.65
You save:  ₪150.19
₱5,844.91
List Price:  ₱8,183.11
You save:  ₱2,338.19
¥15,263.97
List Price:  ¥21,370.17
You save:  ¥6,106.20
MX$2,017.41
List Price:  MX$2,824.46
You save:  MX$807.04
QR366.65
List Price:  QR513.32
You save:  QR146.67
P1,333.57
List Price:  P1,867.05
You save:  P533.48
KSh12,970.21
List Price:  KSh18,158.81
You save:  KSh5,188.60
E£4,927
List Price:  E£6,898
You save:  E£1,970.99
ብር12,449.32
List Price:  ብር17,429.55
You save:  ብር4,980.22
Kz91,240.87
List Price:  Kz127,740.87
You save:  Kz36,500
CLP$95,873.28
List Price:  CLP$134,226.43
You save:  CLP$38,353.14
CN¥717.84
List Price:  CN¥1,005.01
You save:  CN¥287.16
RD$6,055.25
List Price:  RD$8,477.59
You save:  RD$2,422.34
DA13,333.36
List Price:  DA18,667.24
You save:  DA5,333.88
FJ$223.79
List Price:  FJ$313.32
You save:  FJ$89.52
Q777.28
List Price:  Q1,088.22
You save:  Q310.94
GY$21,036.73
List Price:  GY$29,452.27
You save:  GY$8,415.53
ISK kr13,865.35
List Price:  ISK kr19,412.05
You save:  ISK kr5,546.69
DH992.97
List Price:  DH1,390.20
You save:  DH397.22
L1,803.33
List Price:  L2,524.74
You save:  L721.40
ден5,745.21
List Price:  ден8,043.53
You save:  ден2,298.31
MOP$805.11
List Price:  MOP$1,127.19
You save:  MOP$322.07
N$1,759.61
List Price:  N$2,463.52
You save:  N$703.91
C$3,699.91
List Price:  C$5,180.02
You save:  C$1,480.11
रु13,573.31
List Price:  रु19,003.18
You save:  रु5,429.86
S/377.16
List Price:  S/528.04
You save:  S/150.87
K403.65
List Price:  K565.12
You save:  K161.47
SAR375.56
List Price:  SAR525.80
You save:  SAR150.23
ZK2,737.45
List Price:  ZK3,832.54
You save:  ZK1,095.09
L464.12
List Price:  L649.79
You save:  L185.66
Kč2,355.50
List Price:  Kč3,297.80
You save:  Kč942.29
Ft37,975.20
List Price:  Ft53,166.80
You save:  Ft15,191.60
SEK kr1,081.23
List Price:  SEK kr1,513.76
You save:  SEK kr432.53
ARS$99,921.46
List Price:  ARS$139,894.04
You save:  ARS$39,972.58
Bs696.34
List Price:  Bs974.91
You save:  Bs278.56
COP$432,772.49
List Price:  COP$605,898.81
You save:  COP$173,126.31
₡51,433.28
List Price:  ₡72,008.65
You save:  ₡20,575.37
L2,536.97
List Price:  L3,551.87
You save:  L1,014.89
₲786,220.78
List Price:  ₲1,100,740.54
You save:  ₲314,519.76
$U4,173.81
List Price:  $U5,843.51
You save:  $U1,669.69
zł403.39
List Price:  zł564.76
You save:  zł161.37
Already have an account? Log In

Transcript

Hello, in this video, I am going to show you function overriding. So function overriding is when we have a class that extends, you know, another class, and the parent class has a function, let's say open door. And we, you know, let's say we want all the other functionality of that class, but that one particular function, we want it to be slightly different, but we want the same name. And that's what override it. So we override that functionality. And we have the print on info as well.

So for the understand demonstrating on the open door to override the functionality, as you can see, when I run it to open door, and I'm gonna say doors opening, that's where I want to be in the beauty say, all you have to do is literally just put the function in that same fashion, you know, this right here and now if I was to echo and say, door opening. Now far below that, as you can say, says door is opening, even though it's still calling the constructor and destructor from this class, and this ultimately the vehicle class, which the car class is inheriting from, but because what it does, same with the constructor and the destructor, it looks in the child class first to the class that you create an object, if it exists there, it will use that particular one. If it does that, it will go to the parent and look the exists there.

If not, you'll go to the you know, the parents parent, if that, you know inherit from another class. And until it finds it unless you you know, try to call a function that doesn't exist, then he'll give you an error. So that is function overriding nothing more to it than that. You can override it, you know override functions that return value. Maybe in this case, this one doesn't return a value, and you want this one to return a value that's possible. As an extra task, I want you to implement that as another extra task.

I want you to implement a function, let's say in this class that takes in some values, then implemented here in the same fashion that takes in the same amount of value, but it does something different with it. One might echo out, you know, two numbers added together. The other one might just return that result here. So you could store in a variable and use it later on. But yeah, that is function overriding simple stuff, but really useful. If you have any questions, feel free to pop me a message.

And as usual, I look forward to seeing you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.