QUIZGUM

Coding Class

Quizgum : overriding

overridng

I'll find out about overriding.
It's hard to say but simple.
It means that the methods of the parent class override or add functionality to the child class.
In other words, when there is a method called hello() in the parent class, create and use the method hello() with the same name in the child class.

<?php

    class GoogleCar
    {
        public function stateOfTheArtAIDrivingSystem()
        {
            return "Google AI Driving";
        }
    }

    class Car extends GoogleCar
    {
        public $wheels;
        public $doors = 4;
        protected $color = 4;
        private $size;
        private $company;

        public function stateOfTheArtAIDrivingSystem()
        {
            return "AI driving, which adds functionality to existing Google AI driving, uses IOT to connect to all vehicles, connects the car and the human brain, stops the brain while driving, and accidents can never happen without human intervention";
        }
    }
    $ever = new Car;
    echo $ever->stateOfTheArtAIDrivingSystem();
?>

This method is called overriding.
Redefine functionality by identifying the names of the methods of the parent class.
If the method name is the same, you can see that the method of the child class is called, not the parent class.
Result of the code above

Result

If a method is really important you may want to make sure that nobody can override it. Next we'll learn how to make it impossible to override.