Changes between Version 1 and Version 2 of Ticket #314, comment 5


Ignore:
Timestamp:
2013-07-12T17:50:57+02:00 (15 months ago)
Author:
moo
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #314, comment 5

    v1 v2  
    99<?php 
    1010if(class_exists('SomeClass')) return; 
    11 install class "SomeClass'; 
     11install class "SomeClass"; 
    1212}}} 
    1313and because SomeClass is top level class, it is installed immediately in the middle of compiling. 
    14 in debug1.php case, the install success. it then clear the code "install class 'SomeClass'" so it won't install again when the code is executed. this is early binding. early binding is "before" the code get executed, before your "if class_exists" 
     14in debug1.php case, the install success. it then clear the code "install class 'SomeClass'" so it won't install again when the code is executed. this is early binding. early binding is "before" the code get executed, before your "if class_exists". 
    1515but for debug2.php, install will fail due to "class already exists", and it will give up, so the class will only be install after this php is executed (include=execute) exactly at that line of opcode, this is called late binding. 
    1616late binding happens after your "if class_exists" 
     
    1919 
    2020Even though your code seems to work, it's not actually what it looks like to you. 
     21The reason no error is thrown, is because it's a PHP built-in behavior. not because your "if" checking 
    2122You'll see the following code output "true" without any opcode cacher, the original PHP behavior: 
    2223devel.php