This : "&"
Posted: Sat Jul 28, 2007 9:18 am
Hello
From:php|architect’s Guide to PHP Design Patterns
$db =& new MysqlConnection(DB_USER, DB_PW, DB_NAME);
Thanks
From:php|architect’s Guide to PHP Design Patterns
Why does he use this " &" in this code?
Sample Code
The Factory pattern encapsulates the creation of objects. You can create a Factory within the object
itself or in an external Factory class—the exact implementation depends on the needs of your application.
Let’s look at an example of a Factory.
The application code below repeats the same code to create a database connection in multiple
places:
// PHP4
class Product {
function getList() { $db =& new MysqlConnection(DB_USER, DB_PW, DB_NAME);
//...
}
function getByName($name) { $db =& new MysqlConnection(DB_USER, DB_PW, DB_NAME);
//...
}
//...
}
[/b]
$db =& new MysqlConnection(DB_USER, DB_PW, DB_NAME);
Thanks