Home » PHP » What is the abstraction in PHP?

What is the abstraction in PHP?

Abstraction is the concept of moving the focus from the details and concrete implementation of things, to the types of things (i.e. classes), the operations available (i.e. methods), etc

class A {
	private $isOn = false;

	public function on() {
		$this->isOn = true;
	}

	public function Off() {
		$this->isOn = false;
	}
}

$obj = new A();
$obj ->on();
$obj ->off();

In the above class example, we can not do much with it except turning it on and off. The class A is an abstraction of a real A in a very simple use case.

Check Also

What is the inheritance in PHP?

Inheritance is the process in which object of one class acquire the properties of another …

Leave a Reply

Your email address will not be published. Required fields are marked *