note 4604 deleted from function.eval by jimw
| From: | jimw@php.net | Date: | Sat, 08 Dec 2001 23:22:27 +0000 |
| Subject: | note 4604 deleted from function.eval by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-22313@lists.php.net to get a copy of this message | ||
For people doing cross version PHP development, use eval() to dynamically define functions that
exists in PHP4 but not PHP3. For example:
<PRE>
if(floor(phpversion()) == 3)
{
eval('
function in_array($needle, $haystack)
{
reset($haystack);
while(list($key, $val) = each($haystack))
{
if($val == $needle)
{
return true;
}
}
return false;
}
');
}
</PRE>
You can just add the eval(' ... ') without reformatting your code. Need to replace any \
with \\ however.