Technology Programming

How to Use Inheritance in PHP

    • 1). Right-click the PHP file that contains your class. Click "Open With," then click the PHP editor you use to create your PHP classes.

    • 2). Add the "extends" keyword to your class. For example, "class engine extends car" (without quotes) is an example of an "engine" class that inherits the "car" class. The "extends" keyword lets the "engine" class inherit the "car" class.

    • 3). Press the Ctrl and S keys to save the code changes. If you have a debugger in your compiler, click the "Run" button to run the changes in a debugger to check for any syntax errors.



Leave a reply