I have something like that $first="echo 'Hello';"; $intro 'eval ($first)'; eval("\$intro = \"$intro\";"); Code (markup): The output is eval ( echo 'Hello'; ); Code (markup): But I want to display only Hello .. how I can fix this- to execute the first eval then the second.
To answer your question: <?php $first="echo 'Hello';"; $intro='eval ($first);'; eval($intro); ?> PHP: Output: Hello However. You would be well advised to do this another way - read up on eval if unsure why and remember; " If eval() is the answer, you're almost certainly asking the wrong question " (Rasmus Lerdorf, creator of PHP) Without knowing what you are trying to do; <?php $first = "Hello"; $intro = "first"; print $$intro; ?> PHP: Output: Hello
Thank you .. works perfect. I want to use it for a template file that contains encoded php code. So I want to use eval to execute the decoded php code If eval is not good could you recommend another solution? Thank you again.
No problem at all. I don't understand why people bother encrypting data in free themes; It serves as a hinderance to those that are not familiar with editting the file, but in most cases these people done understand HTML either - or wordpress / themes for that matter, hence why they use a free theme. Its also trivial to decode it anyway in most cases, is it really worth your time? If the requirement is to leave the link then so be it; most honest people will adhere to this but theres always going to be scumbags that ignore it, its the same with anything really, articles, images etc.... given the type of sites these people build, they are probably doing you a favour anyway, you dont really want them linking to you ( Personally, If i don't have the time to create my own, i always leave the link in place as a "thanks" to the author for saving me a few hours .... or if i really like it I end up buying the version that lets me remove it...... )
I disagree. I think eval() get's a bad wrap because of people's inability to use it safely. If used carefully, it can be quite useful.
I aggre Luke, eval gets a bad wrap because it's only common use is to be useless or a security hole. The only good use of it I have seen is in Drupal's debugging module Devel.