Simplified example of a class:
class Table extends TableAbstract{
protected static $tablename;
function __construct($str){
$this->tablename = "table_" . $str;
$this->insert(); // abstract function
}
}
When I’ve used classes like this in the past I’ve assigned the $tablename directly when writing the class. This time however I would like it to be decided by the constructor. But when I then call the function referencing $tablename the variable seems to be empty, when I echo the SQL.
What am I doing wrong, or could someone suggest a way to achieve what I want here?
Thanks for any comments/answers..
As the property is
static, access it usingTable::$tablename– or alternativelyself::$tablenameto refer implicitly to the current class.