Re: Structured Code vs. Performance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robert Cummings wrote:
On Thu, 2007-11-29 at 12:13 +0000, Stut wrote:
Not ;). There is no such thing as a compile-time definition in PHP.

There certainly is...

<?php

if( !function_exists( 'file_put_contents' ) )
{
    $def = <<<_
function file_put_contents
        ( \$filename, \$data, \$flags=0, \$context=null )
        {
            // :)
        }
_;
eval( $def );

}

?>

Now, I'm not necessarily advocating this style of compatibility
programming, but I remember seeing something like it in PEAR. I think it
might have been the pear SOAP classes where the classes had to be
declared dynamically.

That's a runtime definition. It has to be. The function_exists function *cannot* be "run" at compile-time to see what the result is, so it must happen at runtime.

I think maybe the confusion is over terminology. In my mind Zend Studio would not let me step through a compile-time process, but it's looking likely that that's precisely what it's doing if I'm to believe everything I'm reading.

Here's what I see when a file is included... I can step through each function definition line (function ...), and at the same time it executes any inline code outside of the functions. That seems like a runtime process to me. If there is a function definition contained within the file, or a function defined within a function, the debugger does not hit that definition unless the condition matches or the function is called.

To me this indicates that PHP defines entities at run time. It's possible that it also defines them at compile-time, but I don't know the internals well enough to know.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux