strpos() 使用注意事項

191 月

strpos() 使用注意事項

strpos()
http://www.php.net/manual/en/function.strpos.php

在使用 strpos() 時,一定要先確保第二個參數不可以為空值,不然就可能發生 Empty delimiter 的錯誤警告。

程式碼:

<?php
// 底下將產生 Empty delimiter 的錯誤警告
// Warning: strpos() [function.strpos]: Empty delimiter in C:\wwwroot\test_strpos.php on line 6

$mystring = 'abc';
$findme   = '';
$pos = strpos($mystring, $findme);
?>
Posted by admin  Posted on 19 1 月 
  • PHP
  • Post Comments 0