<?php spl_autoload_register(function($cname){ if ($cname == 'IMyInterface') { interface IMyInterface { // Use any class or interface constant as value of FOO. // I'll just use some constant available out of the box, to keep it simple: const FOO = FilesystemIterator::CURRENT_AS_PATHNAME; } } elseif ($cname == 'Foo') { class Foo implements IMyInterface {} } elseif ($cname == 'Bar') { class Bar extends Foo implements IMyInterface {} } }); // Foo is super-class for Bar. // uncomment below line to trigger the error: $F = new Foo(); // this should run without errors at any time, but if Foo is instantiated // prior to this line, then the error is triggered: $B = new Bar();
You have javascript disabled. You will not be able to edit any code.