Array object error (solved)
Posted: Wed Jun 02, 2010 3:40 pm
I have a very simple class that i'd like to return an array.
privilege.class.php
main.php
I'm getting an error:
Undefined property: privileges::$type
privilege.class.php
Code: Select all
class privilege {
public function __construct(){
}
function p($app) {
// run SQL to get privileges for $app
// hard coding the privileges for now
$type = array("Read"=> "R", "Write"=> "W", "Update"=> "U", "Delete"=> "D");
return $type;
}
}
Code: Select all
$privilege = new privileges();
$privilege->p(APP_NAME);
// this is how I'd like to use the array items
echo $privilege->type['read'];
echo $privilege->type['write'];
echo $privilege->type['update'];
echo $privilege->type['delete'];
Undefined property: privileges::$type