<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
<title>Suinasia(メソッド名)</title>
<subtitle>「メソッド名」なエントリー</subtitle>
<link rel="alternate" type="text/html" href="http://suin.asia/tag/%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89%E5%90%8D"/>
<link rel="self" type="application/atom+xml" href="http://suin.asia/feed/atom/tag/%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89%E5%90%8D"/>
<author>
<name>suin</name>
</author>
<updated>2012-02-10T09:17:47Z</updated>
<id>http://example.com/atom1.xml</id>
<entry>
<title>PHP5でキーワードを関数名にするとエラー</title>
<link href="http://suin.asia/2008/05/18/using-keyword-as-function-name-occurs-error-php5.html"/>
<summary>&lt;p&gt;PHP5(5.2.4で確認)では、つぎの様なキーワードを関数名とするメンバ関数を作るとエラーになります。&lt;a href=&quot;http://oregonstate.edu/cws/docs/systems/software/php5troubleshooting&quot;&gt;Troubleshooting PHP5 Problems&lt;/a&gt;&lt;/p&gt;

&l...</summary>
<published>2008-05-18T05:43:54Z</published>
<updated>2008-05-18T05:43:54Z</updated>
<id>http://suin.asia/2008/05/18/using-keyword-as-function-name-occurs-error-php5.html</id>
<category term="PHP" label="PHP" scheme="http://suin.asia/tag/PHP" />
<category term="メソッド名" label="メソッド名" scheme="http://suin.asia/tag/%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89%E5%90%8D" />
<content type="html" xml:lang="ja" xml:base="http://suin.asia/tag/%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89%E5%90%8D">
<![CDATA[<p>PHP5(5.2.4で確認)では、つぎの様なキーワードを関数名とするメンバ関数を作るとエラーになります。<a href="http://oregonstate.edu/cws/docs/systems/software/php5troubleshooting">Troubleshooting PHP5 Problems</a></p>

<pre><code class="php">
	protected function catch()
	{}
</code>
</pre>
<p>catchの他にも、abstract・clone・final・implements・interface・private・protected・public・throw・tryなどをメソッド名にするとエラーが起こるらしいです。</p>
<blockquote>Parse error: syntax error, unexpected T_ABSTRACT, expecting T_STRING<br />
Parse error: syntax error, unexpected T_CATCH, expecting T_STRING<br />
Parse error: syntax error, unexpected T_CLONE, expecting T_STRING<br />
Parse error: syntax error, unexpected T_FINAL, expecting T_STRING<br />
Parse error: syntax error, unexpected T_IMPLEMENTS, expecting T_STRING<br />

Parse error: syntax error, unexpected T_INTERFACE, expecting T_STRING<br />
Parse error: syntax error, unexpected T_PRIVATE, expecting T_STRING<br />
Parse error: syntax error, unexpected T_PROTECTED, expecting T_STRING<br />
Parse error: syntax error, unexpected T_PUBLIC, expecting T_STRING<br />
Parse error: syntax error, unexpected T_THROW, expecting T_STRING<br />
Parse error: syntax error, unexpected T_TRY, expecting T_STRING</blockquote>
<p>いまのところ解決策はないようなので、PHP４を意図して、abstract・clone・final・implements・interface・private・protected・public・throw・tryなどをメンバ関数にしたスクリプトをPHP５で動かす場合は注意する必要があります。一時的な回避策としてはメソッド名を変える方法があります。</p>
]]>
</content>
</entry>
</feed>
