Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 412 Vote(s) - 3.66 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP Object Inheritance

#1
Introduction
In this article we will be creating objects and demonstrating inheritance. If you do not know how to create a class in PHP then this tutorial may not be for you. The base class is sometimes called the super class. In PHP the extend keyword is used to inherit from another class. You can also inherit from a class that is being inherited from another class.

UML
Showing object inheritance in UML is pretty simple, its a line from the base class to the child class, the arrow is an outline and not solid, as pictured below. The Car class is inheriting the base class, Vehicle.

[Image: 85sqEhx.png]

Classes
Our classes will be based on vehicles. The base class will be Vehicle. We can create other classes and inherit the methods/functions of the base class. The above UML is converted into PHP (below) to show how the inheritance works.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


The Car class above will automatically have a color variable/attribute. You can use the changeColor method from the base class to set the color of the Car class.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Overloading
You can add your own method in the child class to overload the original method in the base class.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


References
  • [To see links please register here]

  • [To see links please register here]

  • [To see links please register here]

  • [To see links please register here]

Reply

#2
Simple, yet well detailed guide.

I don't come across too many tutorials referencing classes.
Good work.
Reply

#3
great work on your tutorial.
Reply

#4
good work thanks mate !!
Reply

#5
great work on your tutorial.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through