Skip to content

Instantly share code, notes, and snippets.

Created January 16, 2014 13:10
What would you like to do?
Pequeño ejemplo de Lazy Loading en una clase en PHP
class User {
private $_db = null;
public function setDB(DBClass $db) {
return $this->_db = $db;
public function getDB() {
if(null == $this->_db) {
$this->setDB(new DBClass());
return $this->_db;
public function getUserByID() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment