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 回答