I know eval
should be avoided in JavaScript for speed and security reasons. But in the case of PHP, rarely is security ever mentioned. More often, it\'s your pr
i completely agree with previous answers in the point that eval is evil, and i never use it in my code.
but in one situation i haven't managed to avoid eval. i have not much experience in php, so i will be glad if someone advises me how can i rewrite the code without 'eval'. it that situation i had a class name stored in a variable, and i had to call a static method on that class, classname came from a trusted source. so i had to write something like this:
eval("\$result = $className::methodName()");
(because you cannot just write $className::methodName() );