Possible Duplicate:
declare property as object?
class core
{
public $dbh = new PDO("mysql:dbname=newdbnaem;host=1.1.1.1:1111", "owner", "passwordlulz");
function superman() {}
}
gives me a syntax error on the closing tag of the function.
Possible Duplicate:
declare property as object?
class core
{
public $dbh = new PDO("mysql:dbname=newdbnaem;host=1.1.1.1:1111", "owner", "passwordlulz");
function superman() {}
}
gives me a syntax error on the closing tag of the function.
Only constant values can be used as initializers for class properties. Do it in the constructor:
class core {
public $dbh = null;
public function __construct() {
$this->dbh = new PDO("mysql:dbname=newdbnaem;host=1.1.1.1:1111", "owner", "passwordlulz");
}
}
This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated.