[wp-hackers] function_exists - user woes
Stephen O'Connor
steve at stevarino.com
Sat Jul 31 01:57:03 UTC 2004
garett at harnish.ca wrote:
>Hmmm. Depends, what versions of PHP does wordpress have to support? So
>far we haven't strayed too far from PHP 3.0.3 supported functions. If we
>can use PHP4 functions, then this is an even better idea:
>
Theoretically speaking, all WP weblogs are at least running under PHP
4.1. http://wordpress.org/about/requirements/
[ I know the parameter style is another thread, but it's coming into
play here so forgive and bear with me if you find this a bit off topic. ]
You brought up the func_num_args function, and I don't think I've ever
seen that one before. Very neat and I'll be sure to use that later (I've
always wondered how PHP did those [, args...] argument). But to be
honest I'm rooting for the URI-parameter camp for a few reasons. It's
obvious that as the core functions become more complicated that we're
going to need to specify which parameters we wish to define. And so far
there have been two methods to achieve this: passing associative arrays
and defining a URI-syntax. Object-oriented syntax is considered
unfriendly for template use, so I see no reason why associative arrays
would be permitted. And that leaves us with our wanna-be URI's. ;)
Another good point would be easy migration to template-tags. A simple
tag such as:
<wp:xyz_photos args="foo=bar;x=6" />
Could be parsed with a single regular expression:
if( preg_match_all('/<wp:([^ >]+)( args="([^"])")? \/>/', $data,
$matches, |PREG_SET_ORDER| ) ) {
foreach( $matches as $match ) {
$func_name = $matches[1];
if( isset( $matches[3] ) ) {
$func_args = $matches[3];
}
if( func_exists( $func_name ) ) {
[ you know the rest ]
}
}
}
Although arguably you could now split up your arguments into seperate
xml-attributes and have the advantage of not url-encoding your ampersands.
Again, this is all food for thought and I really hate getting so far off
topic. :)
- Stephen
More information about the hackers
mailing list