A Little Noise

November 15, 2005

Static Variable Variables

Filed under: PHP Gotchas — snoyes @ 4:00 am
<?php
  class A {
    static function b() {
      echo "It works\n";
    }
  }
  $theClass = "A";
  $x = new $theClass;

  /* Are any of the following legal? Which? */

  A::b();
  $x->b();
  $theClass::b();
?>

Show Answer ▼

1 Comment »

  1. Have you actually tried running this? All three work. =b

    Comment by RW — February 19, 2014 @ 5:03 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress