如此简单的strpos为什么不能执行? 本帖最后由 gnhao144 于 2011-09-16 12:11:35 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php$html='<tr> <td align="center">没有可以!</td>';if (strpos($html, 'center')){}else{ echo 'null!';}?> 能否指点下原理。的确可以解决。不是说没找到反回false莫。 对呀,没有找到返回falseif(false == strpos($html,'center')){ echo '<div class="error_info">不存在!</div>'; exit();}!= 是不等于== 才是等于 <?php$html='<tr> <td align="center">没有可以!</td> ';header ( 'Content-Type: text/html; charset=gbk' ); if(false != strpos($html,'center')) { echo '<div class="error_info">不存在!</div>'; exit(); }?>红色字里面有空格还有你这段程序正确 <?php$html='<tr> <td align="center">没有可以!</td> ';header ( 'Content-Type: text/html; charset=gbk' ); if(strpos($html,'center')!==false) { echo '<div class="error_info">不存在!</div>'; exit(); }?>最好是!== 不好意 回错了 strpos($html,'center')===false 是不存在centerstrpos($html,'center')!==false 是查找到了‘center’<?php$html='<tr> <td align="center">没有可以!</td> ';header ( 'Content-Type: text/html; charset=gbk' ); if(strpos($html,'center')===false) { echo '<div class="error_info">不存在!</div>'; exit(); }?> if(false != strpos($html,'center'))改为:if(strpos($html,'center') === FALSE)这个是PHP手册推荐的标准写法 如何生成“密码重置”那种“一次性链接” 最新的新浪PHP面试题(MySQL数据库,一天一万条以上的增量,怎么优化?) 求一段正则 急!!!关于php使用sendmail发邮件的问题 关于字符匹配的问题,比较头疼 一个用户注册的问题 我想问一下` htmil怎么插入ActiveX文本框控件` 如何优化sql语句,使得占用系统资源更少 $_post无法得到post过来的数据! 求无闪烁聊天室代码? 链接 求指教,安装pear之后怎么应用啊?
<?php
$html='<tr>
<td align="center">没有可以!</td>';
if (strpos($html, 'center')){}else{
echo 'null!';
}
?>
{
echo '<div class="error_info">不存在!</div>'; exit();
}!= 是不等于
== 才是等于
$html='<tr>
<td align="center">没有可以!</td>
';
header ( 'Content-Type: text/html; charset=gbk' );
if(false != strpos($html,'center'))
{
echo '<div class="error_info">不存在!</div>'; exit();
}
?>
红色字里面有空格
还有你这段程序正确
$html='<tr>
<td align="center">没有可以!</td>
';
header ( 'Content-Type: text/html; charset=gbk' );
if(strpos($html,'center')!==false)
{
echo '<div class="error_info">不存在!</div>'; exit();
}
?>
最好是!==
strpos($html,'center')===false 是不存在centerstrpos($html,'center')!==false 是查找到了‘center’
<?php
$html='<tr>
<td align="center">没有可以!</td>
';
header ( 'Content-Type: text/html; charset=gbk' );
if(strpos($html,'center')===false)
{
echo '<div class="error_info">不存在!</div>'; exit();
}
?>
if(false != strpos($html,'center'))
改为:if(strpos($html,'center') === FALSE)这个是PHP手册推荐的标准写法