Answers for "what is abstract class in php"

4

php interface vs abstract class

Use an interface when you want to force developers working in your 
system (yourself included) to implement a set number of methods on the 
classes they'll be building.
Use an abstract class when you want to force developers working in your 
system (yourself included) to implement a set numbers of methods and you 
want to provide some base methods that will help them develop their child 
classes.
Another thing to keep in mind is client classes can only extend one abstract 
class, whereas they can implement multiple interfaces. So, if you're 
defining your behavior contracts in abstract classes, that means each child 
class may only conform to a single contract. Sometimes this a good thing, 
when you want to force your user-programmers along a particular path. Other 
times it would be bad. Imagine if PHP's Countable and Iterator interfaces 
were abstract classes instead of interfaces.
One approach that's common when you're uncertain which way to go (as 
mentioned by cletus below) is to create an interface, and then have your 
abstract class implement that interface.
Posted by: Guest on October-30-2020
1

abstract class in php

<?php
/**
 * abstract means incomplete
 * abstract class contains atleast 1 abstract function
 * abstract function:- we must declare it but not implement it, it can not contain body
 * you can't create object of abstract method
 * abstract class, child class must contain abstract function
 */
abstract class Bank
{
    abstract function id_proof();
}
class Hdfc extends Bank
{
    function id_proof()
    {
        echo "hdfc bank";
    }
}
class Axis extends Bank
{
    function id_proof()
    {
        echo "<br>axis bank<br>";
    }
}

$obj = new Axis();
$obj -> id_proof();

$obj1 = new Hdfc();
$obj1 -> id_proof();
?>
Posted by: Guest on October-05-2021
12

what is abstract class in php

when we use abstract classes? supposably we have class Car. 
you don't want to use it directly. you need extend this class. 
thats why you must declare this class as abstract. 
then you only can extend this class with all methods.
Posted by: Guest on October-16-2021
4

abstract function php

abstract class absclass { // mark the entire class abstract
    abstract public function fuc();
}
Posted by: Guest on June-06-2021
1

php abstract class static method

Answer
  https://stackoverflow.com/questions/41611058/why-does-php-allow-abstract-static-functions/41611876
Posted by: Guest on July-13-2021
0

php abstract class constant

abstract class Hello {
    const CONSTANT_1 = 'abstract'; // Make Abstract
    const CONSTANT_2 = 'abstract'; // Make Abstract
    const CONSTANT_3 = 'Hello World'; // Normal Constant
    function __construct() {
        Enforcer::__add(__CLASS__, get_called_class());
    }
}
Posted by: Guest on June-17-2020

Code answers related to "what is abstract class in php"

Browse Popular Code Answers by Language