【发布时间】:2017-05-14 20:22:36
【问题描述】:
我是面向对象编程的新手。我需要访问子类中抽象父类中生成的 $key 变量的内容。如何在 postAction() 方法中获取 $key 变量的内容?
abstract class ApiControllerAbstract extends Zend_Rest_Controller {
public function init() {
$cryptoHelper = new Application_Model_CryptoHelper;
$pass = '';
$salt = '';
$passwordIterations = 100;
$keySize = 32;
$iv = "";
$key = $cryptoHelper->getKey($pass, $salt, $passwordIterations, $keySize);
}
}
class Api_SubscribersuploadController extends ApiControllerAbstract {
public function postAction() {
// I need to access contents of key variable from here.
echo parent::$this->key;
}
}
我尝试使用echo parent::$this->key; 但它没有显示任何内容。
【问题讨论】:
-
都回显父级::$this->key;并回显 $this->key;不起作用。