add-memberalign-toparrow-leftarrow-rightbellblockcalendarcamerachatchevron-leftchevron-rightchevron-small-downchevron-upcircle-with-crosscomposecrossfacebookflagfolderglobegoogleimagesinstagramkeylocation-pinmedalmoremuplabelShape 3 + Rectangle 1pagepersonpluspollsImported LayersImported LayersImported LayersshieldstartwitterwinbackClosewinbackCompletewinbackDiscountyahoo

Re: [lampsoftware-8] PHP abstract function overloading

From: Robert G.
Sent on: Thursday, November 1, 2007 11:57 AM
Because you declared the doSomething method as abstract you need to actually define that method in the child class. So your Foobar class has to have a method, with a body, called doSomething because it is extending the Test::doSomething abstract method. You could easily define that method as:

public function doSomething() {}

to get rid of the error for your testing.


Chris Verges <[address removed]> wrote:
Hey all,

I'm having a bit of a conundrum with regards to overloading an abstract
function in PHP. I was going to use the magic function __call() to handle
the overloading rather than writing my own argument parsing routines, but it
doesn't seem to allow me. Here's the sample code:

abstract class Test {
abstract public function doSomething();

class Foobar extends Test {
public function __call($method, $arguments) {
if ( $method == "doSomething" ) {
echo "DO SOMETHING!\n";
} else {
echo "What?\n";

$tmp = new Foobar;

When I run it, this is the error I get:

Fatal error: Class Foobar contains 1 abstract method and must therefore be
declared abstract or implement the remaining methods (Test::doSomething) in
/home/squirrel/abstract-call/test.php on line 15

I'm thinking I might just have to bite the bullet, but I wanted to check
first. Any ideas?


Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Chris Verges ([address removed]) from The Silicon Valley LAMP Meetup Group.
To learn more about Chris Verges, visit his/her member profile:
To unsubscribe or to update your mailing list settings, click here: Customer Service: [address removed]
632 Broadway New York NY 10012 USA

Let no corrupt word proceed out of your mouth but what is for necessary edification that it may impart grace to the hearers.
Eph. 4:29

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy