By Island Usurper on
This is just a question meant to satisfy my curiosity. The documentation for drupal_eval() says,
"Using this wrapper also ensures that the PHP code which is evaluated can not overwrite any variables in the calling code, unlike a regular eval() call."
I want to see if anyone can explain why this is so. I suppose it's because of the output buffering, but I don't see any indication that that's right.
Comments
Hm.
I can't explain,
Doesn't look any "safer" to me! I certainly can overwrite if I want.
But it does prevent accidental overwrites of the calling context.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
You are right but you had to use "global" keyword
You are right, it's not safe if you use "global" modifier but you have to explicitely use it beforehand.
I think the documentation should state this fact, that if you want to overwrite a variable you can
do it declaring it with "global". I see it as a feature more than a bug. It simply should be fixed
in the documentation (imho).