• H2GD Part 16: PHP bug #63156

    I raised a defect report ( bug #63156 ) against PHP today with the following title “using if ( expression ) requires functions to be declared before calls”. This blog describes what I was trying to do when I found the problem. When I first developed the oik plugin I delivered it as a suite of activatable plugins similar to simple-facebook-connect. Over time the oik base plugin has become the most important; the sibling plugins taking on secondary roles. I have decided to break the plugin up into multiple plugins, each of the sibling plugins still being dependent upon the oik base but delivered separately, directly from an oik-plugins server, not WordPress.org.

    I wanted to make the transition as simple as possible for the end user, so I have been developing new code to enable this. Part of the code involves performing the relocation of the PHP file for each activatable plugin from within oik to it own directory. Another part of the code attempts to cater for someone who inadvertently attempts to activate both the original code AND the new code. In order to avoid Fatal errors caused by having two functions with the same name I decided to implement some code similar to that found in C header files. #ifndef CONSTANT #define CONSTANT // this is where the function prototypes and other stuff goes #endif The PHP equivalent of this is if ( !defined( 'CONSTANT' ) ) { define( 'CONSTANT'. true ); // this is where the PHP code goes } // end defined It all looked simple enough so I made the changes and then started testing. And that’s when I got

    Fatal error: Call to undefined function bw_trace_plugin_startup() in oik\oik-bwtrace.php on line 58

    Code which had worked for over a year was now producing a Fatal error! I then set about reducing the problem to its simplest. The following code works. It echoes ‘a’ to stdout. So does But this doesn't So why does this work? Why isn't there a Fatal error when a() attempts to call b(). The answer is probably something to do with when the parsing stops and the interpretation begins. Over to the PHP boys to answer this one.



    Last updated:

    August 18, 2014

Today’s word is this:







Tide times from tidetimes.org.uk

Tide Times & Heights for Langstone Harbour on
19th June 2024
03:24 Low Tide ( 1.69m )
10:37 High Tide ( 4.22m )
15:43 Low Tide ( 1.68m )
22:54 High Tide ( 4.48m )

Tide times from tidetimes.org.uk

Tide Times & Heights for Northney on
19th June 2024
03:36 Low Tide ( 1.39m )
10:40 High Tide ( 3.91m )
15:40 Low Tide ( 1.45m )
22:54 High Tide ( 4.16m )