Edit report at http://bugs.php.net/bug.php?id=55043&edit=1
ID: 55043 User updated by: khurramijazm at gmail dot com Reported by: khurramijazm at gmail dot com Summary: not throwing error on wrong syntax Status: Open Type: Bug Package: Class/Object related Operating System: windows7 PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: After researching i narrow down the problem to that in PHP you can declare a reserved keyword as a goto label: because in the above sent bug report php must have thought of it as an goto label i.e. self: $instance = .... i hope it helps Previous Comments: ------------------------------------------------------------------------ [2011-06-12 17:16:34] khurramijazm at gmail dot com Description: ------------ --- >From manual page: http://www.php.net/internals2.objects --- class MyPDO extends PDO { private static $instance = null; function __construct(){ try{ parent::__construct("mysql:host=localhost;port=3306;dbname=blog", "root", ""); parent::setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); }catch(PDOException $e){ echo 'Exception in constructor'.print_r($e->trace(),true); } } static public function getDB(){ if(self::$instance == null){ self:$instance = new MyPDO(); } return self::$instance; } function selectAll($sql){ $stmt = self::$instance->prepare($sql); $stmt->execute(array(":cat_id"=>1)); return $stmt->fetchAll(PDO::FETCH_ASSOC); } } Expected result: ---------------- class MyPDO extends PDO { private static $instance = null; function __construct(){ try{ parent::__construct("mysql:host=localhost;port=3306;dbname=blog", "root", ""); parent::setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); }catch(PDOException $e){ echo 'Exception in constructor'.print_r($e->trace(),true); } } static public function getDB(){ if(self::$instance == null){ self::$instance = new MyPDO();** ERROR SHOULD BE REPORTED HERE WHEN USING self:$instance , it SHOULD BE THE SCOPE RESOLUTION OPERATOR WITH DOUBLE COLON ::...Sorry if it is not a bug but some thing i don't have knowledge of.. } return self::$instance; } function selectAll($sql){ $stmt = self::$instance->prepare($sql); $stmt->execute(array(":cat_id"=>1)); return $stmt->fetchAll(PDO::FETCH_ASSOC); } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=55043&edit=1