2012-01-30 13 views
1

私は小さな列挙型を作成しようとしていますが、私はちょうど立ち往生しています:なぜこれは機能しませんか?定数定義における連結

class.LayoutParts.php:

<?php 
    class LayoutParts { 
     const MAIN = 1; 
     const FOOTER = 2; 
    } 
?> 

class.SupportedLayouts.php:

<?php 
    class SupportedLayouts { 
     const MAIN  = LayoutParts::MAIN; 
     const MAIN_FOOTER = LayoutParts::MAIN.LayoutParts::FOOTER; 
    } 
?> 

それは次のようなメッセージ結果:あなたの助けを

Parse error: syntax error, unexpected '.', expecting ',' or ';' in /*****/class.SupportedLayouts.php on line 4 

感謝を!

よろしく、フロ

+2

http://stackoverflow.com/questions/2236018/how-can-i-concatenate-a-constant-and-a-variable-and-store-it-in-a-class-constant 答えがそこにあるようです。 –

答えて

3

.constまたはプロパティの宣言では許可されていないLayoutParts::MAIN.LayoutParts::FOOTER;文を作り、オペレータです。

値が(例えば)定数式ではなく、変数、プロパティ、演算の結果、または関数呼び出しでなければならないhere

を参照してください。

関連する問題