note 69567 added to ref.overload

From: Date: Mon, 11 Sep 2006 08:00:22 +0000
Subject: note 69567 added to ref.overload
Groups: php.notes 
Request: Send a blank email to php-notes+get-117003@lists.php.net to get a copy of this message
You mix Objectproperty with Arrays. You cant access Arrayelements like Objectproperties. If you want your Code to run correct try this (But i dont think its intended to be used like this): <?php class SillyClass { private $config = array(); public function __construct() { $this->config['fruit'] = 'banana'; $this->config['animal'] = 'monkey'; $this->config['shoppingList'] = array('drink' => 'milk', 'food' => 'cheeseburger'); } //Allow mySillyClass->someProperty style getting of //anything that might happen to be in the $config array //(returns NULL if not in the $config array). public function __get($property) { if(isset($this->config[$property])) { return $this->config[$property]; } return NULL; } } $mySillyClass = new SillyClass(); echo $drinkToBuy = $mySillyClass->shoppingList['drink']; ?> ---- Server IP: 217.13.201.10 Probable Submitter: 194.15.222.131 (proxied: unknown) ---- Manual Page -- http://www.php.net/manual/en/ref.overload.php Edit -- https://master.php.net/note/edit/69567 Del: integrated -- https://master.php.net/note/delete/69567/integrated Del: useless -- https://master.php.net/note/delete/69567/useless Del: bad code -- https://master.php.net/note/delete/69567/bad+code Del: spam -- https://master.php.net/note/delete/69567/spam Del: non-english -- https://master.php.net/note/delete/69567/non-english Del: in docs -- https://master.php.net/note/delete/69567/in+docs Del: other reasons-- https://master.php.net/note/delete/69567 Reject -- https://master.php.net/note/reject/69567 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117003) next »