Dup Ver Goto 📝

PhpAnonymousClasses

PT2/aw/lang/php does not exist
To
32 lines, 77 words, 440 chars Page 'PhpAnonymousClasses' does not exist.

Importing classes without name clashes

<?php
# if p1 and p2 define functions of the same name, is there a clash
# if we include in function scope?
function f1() {
  include("p1.php");
  $g->f();
}
function f2() {
  include("p2.php");
  $g->f();
}
f1();
f2();
<?php
$g = new class {
  function f() {
    echo "hello world\n";
  }
};
<?php
$g = new class {
  function f() {
    echo "goodbye sir\n";
  }
};