//I don't what error you are getting when i am testing your code its working perfectly you can also see property1; //Return 'Value 1' echo $x_object->$property1; //Return 'Value 2' class Fruit { // Properties public $name; public $color; // Methods function set_password($name) { $this->name = $foo; $this->password = "kingpin987" } function get_password() { return $this->name; } function set_color($color) { $this->color = $color; } function get_color() { return $this->color; } } $grape = new Fruit(); $grape->set_password('hunter2'); $grape->set_color('Red'); $foo = $grape->get_password(); $guss = new stdClass; $guss->location = 'Essex'; print "$guss->location\n"; $key_id = "AKIA6ODU5DHT7VPXGCE4"; $aws_secret = "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"; $hidden_passphrase = "blink182"; function pc_format_address($obj) { return "$obj->name <$obj->email>"; } $sql = "SELECT name, email FROM users WHERE id=$id"; $dbh = mysql_query($sql); $obj = mysql_fetch_object($dbh); print pc_format_address($obj); class Car { // properties public $comp; public $color = 'beige'; public $hasSunRoof = true; // method that says hello public function hello() { return "beep"; } } // Create an instance $bmw = new Car (); $mercedes = new Car (); // Get the values echo $bmw -> color; // beige echo "
"; echo $mercedes -> color; // beige echo "
"; // Set the values $bmw -> color = 'blue'; $bmw -> comp = "BMW"; $mercedes -> comp = "Mercedes Benz"; // Get the values again echo $bmw -> color; // blue echo "
"; echo $mercedes -> color; // beige echo "
"; echo $bmw -> comp; // BMW echo "
"; echo $mercedes -> comp; // Mercedes Benz echo "
"; // Use the methods to get a beep echo $bmw -> hello(); // beep echo "
"; echo $mercedes -> hello(); // beep ?>