Is compile-time binding for class B done in script:
require('a.php'); // defines class A
class B extends A { /*code*/ }
No, won't bind (unless some tool loads a.php in compile-time once it
parses 'require' - I don't know about any tools that do that, it's very
hard to do it IMHO) since require is run-time directive, so when parser
is considering "class B extends A" it doesn't yet know what A is.
require_once('a.php'); // defines class A
class B extends A { /*code*/ }
Same as above. "once" here doesn't change anything.
Or only in:
class A { /*code*/ }
class B extends A { /*code*/ }
Here it would bind in compile-time, since A is known.
Also, this code would bind in compile-time in plain PHP:
require('a.php'); /* has class A {} */
require('b.php'); /* has class B extends A {} */
since the B require executes after the A require so that class A is
already known. However, with opcode cache it's more complicated since it
depends on how the particular cache works - with opcode cache there's
actually two compile times - one when script is compiled before caching
and one when engine wants to compile file but it's taken from the cache
- and when exactly B is bound is that case can depend on the particular
cache. I don't know what APC does in this case (probably Rasmus does ;)
--
Stanislav Malyshev, Zend Products Engineer
[EMAIL PROTECTED] http://www.zend.com/