我收到错误,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>';
}
}
答案 0 :(得分: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>';
}
}