Escaping quotation marks in PHP

后端 未结 7 2056
醉梦人生
醉梦人生 2020-11-21 23:49

I am getting a parse error, and I think it\'s because of the quotation marks over \"time\". How can I make it treat it as a whole string?



        
7条回答
  •  自闭症患者
    2020-11-22 00:52

    Use the addslashes function:

     $str = "Is your name O'Reilly?";
    
     // Outputs: Is your name O\'Reilly?
       echo addslashes($str);
    

提交回复
热议问题