<?php
// abstract class
abstract class Greetings
{
// abstract method
abstract public function greet(string $name) : string;
// regular method
public function bye(string $name) : string {
return "Bye, $name\n";
}
}
// extend abstract class
class Main extends Greetings
{
// implement abstract method
public function greet(string $name) : string {
return "Hello, $name!\n";
}
}
$g = new Main();
echo $g->greet("Jake");
echo $g->bye("Jake");
To embed this project on your website, copy the following code and paste it into your website's HTML: