Skip to main content

PHP from quotation mark output



I use a similar form on a regular basis and have just become aware that whenever a single OR double quotation mark is inputted into the form the output to myself (through email) displays the quotation mark as the ASCII code so \' with a backslash ive looked around and dipped into unique character encodings specialentities but cant seem to find anything that will help output it as a normal quotation mark.




Comments

  1. it is magic_quotes_gpc long-time deprecated ancient PHP setting.
    just turn it off

    ReplyDelete
  2. What version of PHP are you using? It sounds like you may have magic quotes enabled, a deprecated "feature" that automatically adds backslashes to quotes in $_GET and $_POST. It is considered bad practice nowadays to use it, so you should make sure it's disabled. See this page for how to check if it's enabled and disable it.

    In general, if you have a string with escaped quotes, you can use stripslashes to get rid of them.

    $str = "\'hello\'";
    echo $str . "\n";
    //\'hello\'
    echo stripslashes($str) . "\n";
    //hello

    ReplyDelete
  3. It is an old security feature from PHP called "Magic Quotes". All Quotes from GET- and POST varables are escaped with the backslash.

    You can disable it by changing the value of magic_quotes_gpc to off in your servers php.ini or manually sanitize the strings using stripslashes($string).

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.