abstract keyword example

<?php

/*An abstract class can not instantiated but can be inherited .. All you have to is just place the abstract keyword bofore a class ….
*/

abstract class bingo
{
abstract public function bin(); // this abstract function means every child of this class must have this function
}
class lit_bingo extends bingo
{
public function bin() // we mention the bin() function in this class cause it is a child class of bingo class and we do not place any abstract keyword before the function name
{
echo “hey i’m little bingo ,… !”;
}
}

$object = new lit_bingo();

$object->bin();
/*Note: Do not try to set up any abstract method in the class that is not an abstract class*/
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s