类的简化示例:
class Table extends TableAbstract{
protected static $tablename;
function __construct($str){
$this->tablename = "table_" . $str;
$this->insert(); // abstract function
}
}
Run Code Online (Sandbox Code Playgroud)
当我过去使用这样的类时,我在编写类时直接分配了$ tablename.但是这次我希望它由构造函数决定.但是当我调用函数引用$ tablename时,变量似乎是空的,当我回显SQL时.
我做错了什么,或者有人建议一种方法来实现我想要的东西?
感谢您的任何意见/答案..