我想打开文件,检查文件中是否存在字符串deosn't写入它。Strstr返回false而不是true
这样做:
$fp=fopen('categories.txt','a+');
$content=fread($fp,filesize('categories.txt'));
if(!strstr($content,$cat)){
fwrite($fp,','.$cat);
}
fclose($fp);
但我得到了写后重复在categories.txt中值。 唯一的问题是我可以期待的是编码问题,但所有文件都是utf-8并且在categories.txt
我只有拉丁符号和几个符号。
任何想法是哪里的问题?
也许你可以试试[mb_strpos](http://php.net/manual/en/function.mb-strpos.php)呢? – powerbuoy 2012-02-16 09:50:52