[PHP-doc 606] Re: mb_strpos

TAKAGI Masahiro matakagi @ osk2.3web.ne.jp
2006年 2月 24日 (金) 21:11:47 JST


高木です。

At Fri, 24 Feb 2006 14:48:26 +0900,
Tadashi Jokagi wrote:
> 
> http://php.net/mb_strpos
> 
> > encoding が省略された場合、 内部文字エンコーディングが使用されます。
> > strpos() が英字のみを受けつけるのに対して、mb_strpos() は needle に 
> > string を 指定可能です。
> 
>       「strpos() が英字のみ」「mb_strpos() は needle に string」という
>     のは意味わかりませんよね.後者は「needle にマルチバイト」じゃない
>     でしょうか?
> 
原文は

If encoding is omitted, internal character encoding is
used. mb_strrpos() accepts string for needle 
where strrpos() accepts only character.

となっているので、(character ではなく) string を指定できるということで
すね。あと、これは strpos ではなく str *r* pos についての説明になって
います。

で、strrpos() のマニュアルを見ると、以下のような記述があります。

Note that the needle in this case can only be a single character in
PHP 4. If a string is passed as the needle, then only the first
character of that string will be used.

Note:  The needle may be a string of more than one character as of PHP
5.0.0.

実際に、
 $ php -v
 PHP 4.3.9 (cgi) (built: Nov 10 2005 20:38:14)
な環境で以下のスクリプトを試してみると、説明されているような結果になり
ました。

<?php
//            0123456789
$theString = "AAAAABCAAA";

print mb_strrpos($theString, "A") . "\n";   // => 9
print strrpos($theString, "A") . "\n";      // => 9
print mb_strrpos($theString, "ABC") . "\n"; // => 4
print strrpos($theString, "ABC") . "\n";    // => 9 (not 4!)
?>

……と長々と書いてしまいましたが、現在の日本語マニュアルの記述が意味不
明であることには完全に同意します。さて、どのように直せばよいでしょうか。
どなたかいい案はありませんか?

# 実は最近、致命的な誤訳をいくつか見つけてしまって少し落ち込み気味です。
#  http://news.php.net/php.doc.ja/1477
#  http://news.php.net/php.doc.ja/1479
# 1477 なんて意味が正反対になってしまっているし……。

-- 
高木 正弘 mailto:matakagi @ osk2.3web.ne.jp


PHP-doc メーリングリストの案内