- 2006-09-27 (水) 22:51
- PHP
この記事の所要時間: 約 1分45秒
PEAR::Mail_mimeDecodeは送信されたメールをパースするクラスなのですが、PHP4.2系環境だと以下のようなNoticeが出てしまいます。
1 | PHP Notice: Use of undefined constant __CLASS__ - assumed '__CLASS__' in /usr/local/lib/php/pear/Mail/mimeDecode.php on line 178 |
これはMail_mimeDecode#decode内で__CLASS__を使用しているために発生します。(__CLASS__は4.3.0からサポート)
アドホックな方法ですがPHP4.2系環境では__CLASS__を以下のように書き換えればokです。
1 2 3 | // determine if this method has been called statically //$isStatic = !(isset($this) && get_class($this) == __CLASS__); $isStatic = !(isset( $this ) && get_class( $this ) == strtolower ( 'Mail_mimeDecode' )); |
2006/10/05追加:
考えてみれば__CLASS__を定義しておけば良いですね。(そういえば前にis_a()で同じような事をしてました。。。)
1 2 3 4 5 6 7 8 | < ?php if (!defined( '__CLASS__' )) { // メソッド内に書くなら define( '__CLASS__' , get_class( $this )); // それ以外なら define( '__CLASS__' , strtolower ( 'Mail_mimeDecode' )); } ?> |
- Newer: CakePHP array-based Active Record
- Older: 1チップMSX
トラックバック:0
- このエントリーのトラックバックURL
- /blog/2006/09/php42_mail_mimedecode.html/trackback
- Listed below are links to weblogs that reference
- PHP4.2系でPEAR::Mail_mimeDecodeを使う from Shin x blog