Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 395 Bytes

php-escape-string.md

File metadata and controls

19 lines (14 loc) · 395 Bytes

PHP Escape String

function escape($str) {
    return str_replace(
        array( '&',     '<',    '>',    '"',      '\''),
        array( '&amp;amp;', '&amp;lt;', '&amp;gt;', '&quot;', '&#039;'),
        $str
    );
}

NOTE: &amp;apos; is not used as it is not a valid HTML entity reference.


Posted Apr 6, 2010.

https://www.darklaunch.com/2010/04/06/php-escape-string.html