I came across this function, and I don't understand how you can have a conditional statement without any curly brackets. Can someone give me and explanation as to why and how this works.
If I include the curly brackets where I instinctively think they should go as shown below it does not replace the $search values with the $replace values.
Conditions without curly braces only apply to the next line in the code. I personally do not omit the curly braces regardless of if its one line due to the readability aspect.
// or can call get_magic_quotes_gpc() which returns a boolean $text = ini_get('magic_quotes_gpc') ? stripslashes($text) : $text;
The search and replace seems a little overboard though. You can run that through htmlspecialchars or htmlentities instead of doing the work yourself. It looks like a syntax error on the forums here, but I'm betting you that its no problem at all.
the placement of the curly brackets may be correct but the reason the function is not working is because you have unclosed quotes
PHP Code:
"\" // string is not closed because of the escape char \"
PHP Code:
"\\" // this string is closed.
I noticed that too, but I'm thinking that its a strip from the forum. I've seen a very similar problem to this not that long ago which causes the pattern typed replacements to show incorrectly when parsed by the [php] tags.
Although for the OP, if it actually is like that (just the single), then yes its definitely a syntax error and needs to be corrected. They can of course just be removed since it searches and replaces the same char.
the forum is causing the problem. I can't get it to display correctly.
thanks again
I have yet to determine WHAT it is that PHP is doing when it destroys those, but can make it difficult if your trying to debug things like regex when you can't see it properly >.<
Thanks for confirming that.