Re: [PHP] Structured Code vs. Performance



On Thu, 2007-11-29 at 16:49 +0000, Stut wrote:
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.

Bleh, just read your comments and then read the comment I quoted and I
find myself needing a morning wakeup slap :) Your comment at the top
says compile-time, not run-time. I'm going to go find a big rock *hehe*.

Cheers,
Rob.
--
............................................................
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
............................................................
.