lang/php/ PhpAnonymousClasses
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";
}
};