top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Seemingly incorrect strict standard in PHP

0 votes
168 views

I've got an abstract class which requires one of the concrete descendants to implement a static function.
The base class will call it using static:: rather than self::. But I'm getting an error at runtime. Static function should not be abstract. It doesn't SEEM right to inhibit this. Am I missing something?
I'm on PHP 5.4.15 (Mac and Centos).

posted Jun 3, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

This change is done on purpose.
From the PHP manual:
"Dropped abstract static class functions. Due to an oversight, PHP 5.0.x and 5.1.x allowed abstract static functions in classes. As of PHP 5.2.x only interfaces can have them."

I believe you could make yourself in trouble when using it, and that's why there is a warning with strict.

It does make sense, because overloading is something that works on classes, and static functions do not reference classes.

answer Jun 3, 2013 by anonymous
Similar Questions
0 votes

recently I have made a form code and attached modules to it. but soon after I have reached an error saying Notice: Undefined index: module in F:\website\webpage\gate.php on line 68

here is the line that was mentioned

   switch ($_GET["module"]) {
    case "settings":
      Include('settings.php');
      break;
    default:
      break;
   }

I am also mentioning the code in the that I showed up ib the link

<a class="nav-link" href="gate.php?module=settings"> Settings </a>

please rectify this error for me and sorry for any in trouble

...