php & Only variables should be assigned by reference
Salut !
Dans mon pattern singleton :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
<?php
require_once("DB.php");
class DatabaseConnection
{
public static function get()
{
static $db = null;
if ( $db == null )
$db = new DatabaseConnection();
return $db;
}
private $_handle = null;
private function __construct()
{
$dsn = 'mysql://root:password@localhost/photos';
$this->_handle =& DB::connect( $dsn, array() );
}
public function handle()
{
return $this->_handle;
}
}
print( "Handle = ".DatabaseConnection::get()->handle()."\n" );
print( "Handle = ".DatabaseConnection::get()->handle()."\n" );
?> |
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
<?php
class DB
{
public static function connect($dsn_, $array_)
{
static $handle;
return $handle;
}
}
?> |
Je ne saisi pas le sens du message
Citation:
PHP Notice: Only variables should be assigned by reference in /src/singleton.php on line 19
Pouvez-vous m'aider ?
merci big_smile