我正在使用codeigniter构建一个多语言网站
我有这个语言文件
$lang['prot_home_1'] = "Our Crash Protection Plan revolutionizes IT support. Traditional IT support firms only help after disaster strikes, and off the shelf anti-virus software requires maintenance to be effective. Our Crash Protection Plan doesn't react";
问题是如果我使用"
来封闭文本,如果我在一个类上调用它,它会破坏字符串,但如果我使用'
来封闭测试,如果我得到像doesn't
这样的单词,它打破了字符串。
解决此问题的最佳方法是什么?
答案 0 :(得分:4)
只需使用转义字符\
即可转义单引号。
$lang['prot_home_1'] = '... Crash Protection Plan doesn\'t react';
答案 1 :(得分:0)
如果你不想每次都逃避引号,你可以使用heredoc
$lang['prot_home_1'] = <<<HTML
Dear, $username<br/><br/>
Our Crash Protection Plan revolutionizes IT support.
Traditional IT support firms only help after disaster strikes,
and off the shelf anti-virus $phpVar software requires maintenance to
be effective. Our Crash Protection Plan doesn't react.
HTML
;