I had never seen anything like it before.
$dbTable = new $dbTable();
Are we saving an instance of an object inside $ dbTable?
Will we convert a string to an object?
Here's the context:
protected $_dbTable; public function setDbTable($dbTable) { if (is_string($dbTable)) { $dbTable = new $dbTable(); } if (!$dbTable instanceof Zend_Db_Table_Abstract) { throw new Exception('Invalid table data gateway provided'); } $this->_dbTable = $dbTable; return $this; }
From the php reference here: http://www.php.net/manual/en/language.oop5.basic.php
We can read:
If the string containing the name of the class is used with a new, new instance of that class. If the class is in the namespace, its fully qualified name should be used when doing this.
But this is similar to the concatenation operation between a string and these "things" :() - without using a period. So I'm still not sure what is going on here.
source share