为什么strpos()函数不能用变量查询?

WBOY
Release: 2016-06-23 13:34:17
Original
1611 people have browsed it

strpos($str,"ABC");
这样可以。

$A="ABC";
strpos($str,$A);
这样就不可以。


这是为什么?


回复讨论(解决方案)

怎么可能呢

$str = "123ABCDEF";$A = "ABC";var_dump(strpos($str, $A));var_dump(strpos($str,"ABC"));
Copy after login
int(3)
int(3)

显然是你传入的数据有问题


嗯,不是这个情况,我问题提的不对。
原本的样子是这个模样:

$sp=$ID[$home[$e]];
$location=strpos($myfile,$sp);

$sp的有值,但$location没有。
什么情况?

具体情况要具体分析
你把那几个变量都打印出来,看看问题出在哪里


哦,知道怎么回事了,$myfile根本就没这个字符串,我没注意看资源文档,应该检查一下的。


不好意思打扰了
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!