namespace blarg;
function time() {
echo "test !开发者_StackOverflow";
}
time();
but ! is it possible to override the "eval" functon ?
namespace blarg;
function eval() {
echo "test !";
}
eval();
?
thanks in advance
According to the answeres :
- eval() is a language construct and not a function, we can't override it 2.Im not really overriding the time() function in my example. I'm just creating a blarg\time() function
I understood
BUT Actually i'm writtin sumting like a debugger and i need to change the default behaviour of php functons or some language construct (e.g eval) Is there anyway to do this ? Is it possible to change the php source and compile it ? (Is there any specific file to edit ?)Note: Because this is a language construct and not a function, it cannot be called using variable functions Manual
So, it can't be overriden as echo/php/include too
namespace blarg;
function time() {
echo "test !";
}
time();
This does not override the builtin time()
function. What this does is create the function blarg\time()
-- that is, both time()
and blarg\time()
exist and can be called, so never was time()
overridden.
When you call time()
in the blarg
namespace, both the builtin time()
and local blarg\time()
functions are candidates to be called; however, PHP will disambiguate by always calling the most local name, which in this case is blarg\time()
.
Now, if we ask if it is possible to introduce a function locally named eval()
, the answer is no, because eval
is a reserved word in the PHP language because of its special meaning -- referred to as a language construct. Other examples of the same nature are isset
, empty
, include
, and require
.
精彩评论