I have been working on this for hours but not able to find the error. Also did searching on Internet but none seems fix to my weird problem. A bit weird as the same code works on different application that I have. The only thing differs is that I am now connecting to Sybase and the previous application connects to MySQL. Here is what I have in DB class:
class DB{
private static $_instance = null;
private function __construct(){
try{
$this->_pdo = new PDO ("dblib:host=host:port;dbname=myDb","username","pwd");
echo 'Connected';
}
catch(PDOException $e){
die($e->getMessage());
}
}
public static function getInstance(){
if(!isset( self::$_instance )){
self::$_instance = new DB();
}
return self::$_instance; //this line generates 500 internal server error in browser console
}
}
My code in index.php
echo DB::getInstance();
That outputs the word "Connected" but in the same time generates 500 code error in my browser's console. I don't really understand why return self::$_instance
is having problem. When I do return 'test'
no error generated. I know I miss something but I could not able to understand why. I am using PHP 5.3 on Ubuntu. Thank you in advance.