Reputation: 7543
I'm working on function like this one:
function foo() {
return '[ = ]';
}
But this returns:
[ @ ]
And I need:
[ = ]
Any ideas?
Upvotes: 1
Views: 957
Reputation: 164809
Your function is returning the correct string.
When you view it in an HTML document, it is interpreted as an entity.
My advice would be to encode the response when you display it, eg
$foo = foo();
echo htmlspecialchars($foo, ENT_QUOTES, 'UTF-8');
Changing your function's return value will probably cause issues later on when you may not want the encoded string.
Upvotes: 1
Reputation: 33769
You could either call htmlspecialchars
on your string before you output it, or you could simply replace the &
in your string with a &
.
Either one will make a browser show =
instead of @
.
Upvotes: 3