Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can confirm that this is a difference with how xcache is compiling/installing the code. By default PHP install's classes during compilation and then removes the class code so that it won't be installed again on execution. This is known as early binding. During this process the install of the second class would fail as the "class exists" and the code will remain intact for execution.</p> <p>Upon execution PHP will have a second go at installing any remaining classes in the same order as the code this is known as late binding. Any classes which are not reached during execution such as in debug2 are not installed and so do not cause an error. This provides a level of flexibility which allows bad practice such as instantiating a class before it is declared. Or in this case avoiding duplicate includes by checking if the class exists rather than being more diligent with your includes or make your life easier by using an autoload.</p> <p>Whilst PHP allows this practice xcache have confirmed that they only execute early binding which in turn forces the class redeclaration error. (see: <a href="http://xcache.lighttpd.net/ticket/314" rel="nofollow">http://xcache.lighttpd.net/ticket/314</a>)</p> <p>As xcache is used a lot in live environments I would recommend against using a return statement without the else. However, as Jon said autoloading is the way to go, or else wrap the class within an else statement.</p> <p>This video shows the inconsistency between xcache and PHP: <a href="http://www.youtube.com/watch?v=VcNLoDvRLDc" rel="nofollow">http://www.youtube.com/watch?v=VcNLoDvRLDc</a></p> <p>P.S. Jon's answer is right with the respect to how PHP parses the page, however I have created this more detailed answer as xcache was also having an effect on the results.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload