Handling apostrophes when generating HTML with PHP

前端 未结 5 781
慢半拍i
慢半拍i 2020-12-22 02:13

I am generating radio buttons based on an XML config values. Sometimes they have apostrophes in the text. When manipulating this data in PHP, I seem to lose everything after

5条回答
  •  情深已故
    2020-12-22 02:57

    You can escape the quotes in the string: value='Government wants to limit employers' communications about unionization' Escaping it will cause this problem to stop.

    PHP does give functions for this, in case your information is in a variable. Just use htmlspecialchars

提交回复
热议问题