0

これでエラーが発生します。NetBeansは、$xml_package宣言の最後の行で何かを予期していると言っています。私が欠けているアイデアはありますか?

ありがとうございました。

class foo
{
    public function __construct()
    {
        public $rateRequest = 'RateV4Request';

        public $xml_request = '<'. $rateRequest. '><Revision></Revision></'.
                              $rateRequest. '>';

        public $xml_package = '<Package><Service></Service><ZipOrigination>
                        </ZipOrigination><ZipDestination></ZipDestination>
                        <Pounds></Pounds><Ounces></Ounces><Container>
                        </Container><Size></Size></Package>';
    }
}
4

1 に答える 1

3

これは、クラスではなく、コンストラクター自体でプロパティを宣言しているためです。

class foo 
{ 
    protected $rateRequest; 

    protected $xml_request; 

    protected $xml_package; 

    public function __construct() 
    { 
        $this->rateRequest = 'RateV4Request'; 

        $this->xml_request = '<'. $this->rateRequest. '><Revision></Revision></'. 
                              $this->rateRequest. '>'; 

        $this->xml_package = '<Package><Service></Service><ZipOrigination> 
                        </ZipOrigination><ZipDestination></ZipDestination> 
                        <Pounds></Pounds><Ounces></Ounces><Container> 
                        </Container><Size></Size></Package>'; 
    } 
} 
于 2012-04-19T21:59:44.773 に答える