Search
 
SCRIPT & CODE EXAMPLE
 

PHP

what is abstract class in php with example

<?php
abstract class Cars
{
    abstract function car_details();
}
class Maruti extends Cars
{
    function car_details()
    {
        echo "Maruti Details";
    }
}
class Honda extends Cars
{
    function car_details()
    {
        echo "<br>Honda Details<br>";
    }
}

class Scoda extends Cars
{
    function car_details()
    {
        echo "<br>Scoda Details<br>";
    }
}

$obj = new Maruti();
$obj -> car_details();

$obj1 = new Honda();
$obj1 -> car_details();

$obj2 = new Scoda();
$obj2 -> car_details();
?>
Comment

abstract function php

abstract class absclass { // mark the entire class abstract
    abstract public function fuc();
}
Comment

what is abstract class in php


<?php
/**
 *Abstract Methods and Classes
 *An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.
 *An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon), like this:
 
 *abstract void car_details(char model, double price);

 *If a class includes abstract methods, then the class itself must be declared abstract, as in:

 *	public abstract class Cars {
 *	   // declare fields
 *	   // declare nonabstract methods
 *	   abstract void car_details();
 *	}
 * When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class. However, if it does not, then the subclass must also be declared abstract.

 * In Abstract class someone can write the definitation and someone can use/extend it, abstract means incomplete.
 * It is not possible to create object of abstract method
 * abstract class contains atleast 1 abstract function, it can have abstract and non abstract methods.
 * abstract function can not contain body or definitation it must declare, but should not have function definitation.
 * abstract class, child class must contain abstract function
 */
abstract class Cars
{
    abstract function car_details();
}
class Maruti extends Cars
{
    function car_details()
    {
        echo "Maruti Details";
    }
}
class Honda extends Cars
{
    function car_details()
    {
        echo "<br>Honda Details<br>";
    }
}

class Scoda extends Cars
{
    function car_details()
    {
        echo "<br>Scoda Details<br>";
    }
}

$obj = new Maruti();
$obj -> car_details();

$obj1 = new Honda();
$obj1 -> car_details();

$obj2 = new Scoda();
$obj2 -> car_details();
?>
Comment

PHP OOP - Abstract Classes

<?php
abstract class ParentClass {
  abstract public function someMethod1();
  abstract public function someMethod2($name, $color);
  abstract public function someMethod3() : string;
}
?>
Comment

php abstract class static method

Answer
  https://stackoverflow.com/questions/41611058/why-does-php-allow-abstract-static-functions/41611876
Comment

PREVIOUS NEXT
Code Example
Php :: laravel post ajax proper csrf 
Php :: parse json nested array form url in php 
Php :: how to insert data in table and fetch in wordpress 
Php :: php unit 
Php :: Session/Session.php error codeigniter 3 
Php :: PHP str_word_count — Return information about words used in a string 
Php :: htaccess redirect https laravel 
Php :: php webpage to string 
Php :: access json with php 
Php :: use smarty variable in php 
Php :: jquery send form data to php 
Php :: symfony connect rabbitMQ 
Php :: convert png to webp in php 
Php :: laravel ecommerce 
Php :: laravel model::query 
Php :: how to call js function from php 
Php :: display error meaages in laravel blade 
Php :: eloquent first 
Php :: laravel request validation rules for create and update 
Php :: laravel validation check value should be one of in array 
Php :: how create page 419 in laravel 
Php :: php round nearest half 
Php :: php get last index of array 
Php :: download xampp php 7.3 
Php :: php integer 
Php :: how to save multiple records in database using laravel 
Php :: laravel set production 
Php :: php join 
Php :: php get multiple url parameters 
Php :: json get/post request in php 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =