|
Posted by Andy Hassall on 02/15/06 23:18
On 15 Feb 2006 12:23:33 -0800, "Bart the bear" <bartthebear@gmail.com> wrote:
>Speaking of this, is there any chance of references to functions in
>PHP?
The closest is create_function() which isn't as good as Perl's ability to pass
code blocks, as you have to embed the anonymous function source in a string.
http://uk2.php.net/create_function
>Also, Perl has qr() construct which compiles regular expressions and
>makes
>things significantly faster. Is there any flag to compile regular
>expression in
>prreg_match?
Looking at the PHP source code, at least for PHP 5.1.2, it already compiles
expressions on first use and keeps the results in a cache - subsequent calls
use the cached compiled version. At least from a quick inspection of
ext/pcre/php_pcre.c, e.g. line 438, within php_pcre_match:
/* Compile regex or get it from cache. */
if ((re = pcre_get_compiled_regex(regex, &extra, &preg_options
TSRMLS_CC)) == NULL) {
RETURN_FALSE;
}
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
[Back to original message]
|