我在PHP中有这个代码:
$_pagi_sql='SELECT * FROM programas WHERE MATCH(titulo, texto,pais) AGAINST ('"$criterio"' IN BOOLEAN MODE) AND operador=34 And validez >= NOW()';
我想把这个字符串放在变量$ _pagi_sql:
中SELECT * FROM programas WHERE MATCH(titulo, texto,pais) AGAINST ('"STH"' IN BOOLEAN MODE) AND operador=34 And validez >= NOW()
但是双引号没有正确存储在变量$ _pagi_sql
中怎么做?
答案 0 :(得分:0)
您可以在单引号前添加斜杠来输入双引号。
$_pagi_sql='SELECT * FROM programas WHERE MATCH(titulo, texto,pais) AGAINST (\'"$criterio"\' IN BOOLEAN MODE) AND operador=34 And validez >= NOW()';
答案 1 :(得分:0)
用双引号替换右手柄侧的单引号:
$_pagi_sql="SELECT * FROM programas WHERE MATCH(titulo, texto,pais) AGAINST ('\"$criterio\"' IN BOOLEAN MODE) AND operador=34 And validez >= NOW()";
或者,摆脱引号,使用heredoc:
$_pagi_sql = <<<SQL
SELECT * FROM programas WHERE MATCH(titulo, texto,pais) AGAINST ('"$criterio"' IN BOOLEAN MODE) AND operador=34 And validez >= NOW()
SQL;