Thursday, September 29

php method access

In PHP, it doesn’t seem to matter what order the static and private / protected / public come in before a static method declaration. Here’s an example:

class whatever {
  public static function foo () { echo "foo called\n"; }
  static public function bar () { echo "bar called\n"; }

And on running:

brennen@exuberance 12:02:54 /home/brennen ★ php test.php
foo called
bar called

Did I know this once and forget it? In a decade+ of writing the stuff, did I somehow just never notice?

p1k3 / 2016 / 9 / 29
tags: topics/php, topics/technical