I am having some difficulty using an array in my class
let's say $_REQUEST['appData'] = array('foo'=>' ABC '}
I am using:
php 5.3
on a windows xP platform
running an Apache server v 2.xx
in a FireFox v 25.01 browser
use firephp, I can see that $p has been populated with the array before I try to access it.
What is the proper syntax for manipulating public variables within a class?
let's say $_REQUEST['appData'] = array('foo'=>' ABC '}
I am using:
php 5.3
on a windows xP platform
running an Apache server v 2.xx
in a FireFox v 25.01 browser
use firephp, I can see that $p has been populated with the array before I try to access it.
What is the proper syntax for manipulating public variables within a class?
Code:
class aFill { public $p; private $c; function addStuff() { // this works $this->c['myArray'] = array(); $this->c['myArray'][0] = 'something'; //returns error "[B]Undefined index: foo[/B]" $this->p['foo']= trim($this->p['foo']); return $this->p; } } $a = new aFill; $a->p = json_decode($_REQUEST['appData'], true); /* calling the method of the class to manipulate the $p property of the class */ $response = $a->addStuff();
Comment