internal or user. But in namespace context I'll have to do something
along the lines of:
if (function_exists('json_encode')) {
$encoded = json_encode($raw);
} else {
$encoded = ::json_encode($raw);
}
What this code is supposed to do? If it's supposed to call namespace's
json_encode in case global one is not defined, I see nothing wrong with
it. If it is intended to call globally defined json_encode, then you just
write ::json_encode, no ifs. The thing is you'd need to do it *ONLY* for
json_encode, and only because you want to do something special with it.
The principle is - common case is free, special cases are available, but
for a "fee" - additional code.
The code is supposed to call the global internal json_encode() if it exists,
and if not, call global user json_encode().
Without namespaces this is achieved in the following way:
$encoded = json_encode($raw); // global user or global internal, doesn't
matter, it's transparent.
But inside a namespace, you'll need to do the above checks since internals
and user functions don't resolve under the same rules.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php