How should I echo a PHP string variable that contains special characters?

前端 未结 4 1207
轻奢々
轻奢々 2021-01-17 09:05

I\'m trying to populate a form with some data that contains special characters (e.g. single quote, double quote,<,>,?,\",\"\".~,,!@#$%^&*()_+}{\":?<<>,./;\'[.]

4条回答
  •  囚心锁ツ
    2021-01-17 09:47

    whats wrong with using a constant ?

    ,?,","".~,,!@#$%^&*()_+}{":?<<>,./;');
    $foo2="'[.]";
    echo constant('foo').$foo2;
    ?>
    

    you need to put the '[.]' into a variable, as a constant will break on a ' (single quote).

提交回复
热议问题