PHP Tutorial
- PHP Tutorial
- Install PHP
- PHP Code
- PHP Echo and print
- PHP Variable
- PHP Variable Scope
- PHP $ and $$
- PHP Constants
- PHP Data Types
- PHP Operators
- PHP Comments
Control Statement
- PHP If else
- PHP Switch
- PHP For Loop
- PHP foreach loop
- PHP While Loop
- PHP Do While Loop
- PHP Break
- PHP Continue
PHP Functions
- PHP Functions
- Parameterized Function
- PHP Call By Value and reference
- PHP Default Arguments
- PHP Variable Arguments
- PHP Recursive Function
PHP Arrays
PHP Strings
PHP Math
PHP Form
PHP Include
State Management
PHP File
Upload Download
PHP OOPs Concepts
- OOPs Concepts
- OOPs Abstract Class
- OOPs Abstraction
- OOPs Access Specifiers
- OOPs Const Keyword
- OOPs Constructor and destructor
- Encapsulation
- Final Keyword
- OOPs Functions
- OOPs Inheritance
- OOPs Interface
- OOPs Overloading
- OOPs Type Hinting
PHP MySQLi
- MySQLi CONNECT
- MySQLi CREATE DB
- MySQLi CREATE Table
- MySQLi INSERT
- MySQLi UPDATE
- MySQLi DELETE
- MySQLi SELECT
- MySQLi Order by
PHP Topics
- Compound Types
- is_null() Function
- Special Types
- Inheritance Task
- Special Types
- MVC Architecture
- PHP vs. JavaScript
- PHP vs. HTML
- PHP vs. Node.js
- PHP vs Python
- PHP PDO
- Top 10 PHP frameworks
- phpMyAdmin
- Count All Array Elements
- Create Newline
- Get Current Page URL
PHP Mail
An abstract class is a mix between an interface and a class. It can be define functionality as well as interface.
- Classes extending an abstract class must implement all of the abstract methods defined in the abstract class.
- An abstract class is declared the same way as classes with the addition of the ‘abstract’ keyword.
SYNTAX:
abstract class MyAbstract
{
//Methods
}
//And is attached to a class using the extends keyword.
class Myclass extends MyAbstract
{
//class methods
}
Example 1
<?php
abstract class a
{
abstract public function dis1();
abstract public function dis2();
}
class b extends a
{
public function dis1()
{
echo "tutorialspro";
}
public function dis2()
{
echo "tech";
}
}
$obj = new b();
$obj->dis1();
$obj->dis2();
?>
Output:
tutorialsprotech
Example 2
<?php
abstract class Animal
{
public $name;
public $age;
public function Describe()
{
return $this->name . ", " . $this->age . " years old";
}
abstract public function Greet();
}
class Dog extends Animal
{
public function Greet()
{
return "Woof!";
}
public function Describe()
{
return parent::Describe() . ", and I'm a dog!";
}
}
$animal = new Dog();
$animal->name = "Bob";
$animal->age = 7;
echo $animal->Describe();
echo $animal->Greet();
?>
Output:
Bob,7 years old,and I’m a dog!woof!