PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I changed the double quotes to single quotes in the create_function() and that seems to have solved the problem...bug or am I missing something about the use of this function? Double quoted strings are possibly disallowed due to variable interpolation??? Actually that makes sense otherwise how would the function know how to distinguish interpolated variables or function variables.
I think I tried that with addslashes -- didn't do the trick tho. What did you have mind? In anycase the problem is solved but just for the sake of curiosity...
PCSpectra wrote:bug or am I missing something about the use of this function?
You're missing the fact that variables in double quotes were interpolated before the string was passed to create_function(). Thus it was receiving "return str_replace('articles', '', );" - it's obviously invalid php syntax. When you changed double quotes to single, the variables stopped being interpolated, and create_function() received 'return str_replace('articles', '', $e); - which was valid.
Like that. Addslashes isn't supposed to escape variables. Anyways, they'd already be expanded by the time any function would be able to run on it, so that would be impossible. This is what addslashes does.