Jump to content

htmlentities questions.


tomfmason

Recommended Posts

When I try something like this..

[code=php:0]
$text = htmlentities($_POST['text'], ENT_QUOTES);
echo $text;
[/code]

and say the text is this before processing..

[list][*]This is a single quote ' and this is a double "[/list]

This is what it looks like after words..

[list][*]This is a single quote \' and this is a double \"[/list]

I am wondering why the quotes are being escaped??

Should I strip the \'s or am I just missing something..

Thanks,
Tom
Link to comment
Share on other sites

htmlentites shouldn't be doing that. Looks your server has setting called magic_quotes enabled. Which automatically escapes quotes returned from a function or user input. You're best of disabling magic_quotes either by editing the php.ini if you can. or by adding the following:
[code]php_flag magic_quotes_gpc Off
php_flag magic_quotes_runtime Off
php_flag magic_quotes_sybase Off[/code]
To a .htaccess file in your servers document root.
Link to comment
Share on other sites

No. As that doesnt fully turn of magic_quotes. that prevents magic quotes from escaping quotes in user input (GET, POST, COOKIE etc). It will not prevent magic quotes from escaping quotes that are in a string that is being retruned form a function. The only way to prevent this is to turn of magic_quotes_runtime in the php.ini, server config file or the .htaccess file.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.