にゃあ

PHP5でキーワードを関数名にするとエラー

PHP5(5.2.4で確認)では、つぎの様なキーワードを関数名とするメンバ関数を作るとエラーになります。Troubleshooting PHP5 Problems


	protected function catch()
	{}

catchの他にも、abstract・clone・final・implements・interface・private・protected・public・throw・tryなどをメソッド名にするとエラーが起こるらしいです。

Parse error: syntax error, unexpected T_ABSTRACT, expecting T_STRING
Parse error: syntax error, unexpected T_CATCH, expecting T_STRING
Parse error: syntax error, unexpected T_CLONE, expecting T_STRING
Parse error: syntax error, unexpected T_FINAL, expecting T_STRING
Parse error: syntax error, unexpected T_IMPLEMENTS, expecting T_STRING
Parse error: syntax error, unexpected T_INTERFACE, expecting T_STRING
Parse error: syntax error, unexpected T_PRIVATE, expecting T_STRING
Parse error: syntax error, unexpected T_PROTECTED, expecting T_STRING
Parse error: syntax error, unexpected T_PUBLIC, expecting T_STRING
Parse error: syntax error, unexpected T_THROW, expecting T_STRING
Parse error: syntax error, unexpected T_TRY, expecting T_STRING

いまのところ解決策はないようなので、PHP4を意図して、abstract・clone・final・implements・interface・private・protected・public・throw・tryなどをメンバ関数にしたスクリプトをPHP5で動かす場合は注意する必要があります。一時的な回避策としてはメソッド名を変える方法があります。


コメント&トラバ

トラックバックを送る

無関係なスパムのトラックバックを防止するため、リンク先で本サイト(suin.asia)への言及が確認されないトラックバックは破棄しています。

トラバURL : http://suin.asia/trackback/14

コメントを書く

お名前* URL
本文*
合い言葉* ←「40theno27」と入力して下さい。
* この記事の話題と関係ないコメントはどんな内容でも削除します。(移動できないので)

トラックバック

トラックバックがないのはさみしいにゃん…。

コメント

コメントはないです。誰かコメント書いてよぅ…。

Author

Submenu

Recent Entries

XOOPS Cube Dev Ring

氷川 XOOPS Module 開発室

Recent Comments

Recent Trackbacks

facebookいいね