您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

请问:数组元素中的单引号

2025/2/2 4:26:39发布41次查看
请教:数组元素中的单引号
如下代码:
function method(){
$str = apply;
$str2 = tony;
$sql = select * from table where 1 =1;
$carray = array( and cad like '%.$str.%', and name like '%.$str2.%');
//echo($carray[0]);
for($i=0;$i   $sql.=$carray[$i];
}
echo $sql;
}
这段代码是为了简便自己先写的,我想问的是为什么输不出$sql,也就是说输不出数组中的元素,当加上echo($carray[0]);这一句的时候,是输不出东西的,是不是数组中的单引号出问题了?
------解决方案--------------------
没有问题啊。
输出:select * from table where 1 =1 and cad like '%apply%' and name like '%tony%'
------解决方案--------------------
php codefunction method() { $str = apply; $str2 = tony; $sql = select * from table where 1 =1; $carray = array( and cad like '%$str%', and name like '%$str2%'); for ($i = 0; $i ------解决方案--------------------
单引号在双引号的字符串里就做单引号用

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product