Well, there are several things at play here.
First, you don't initialize your object correctly. You should write:
$mess =& new Message($message);Why? Because of your constructor:
function Message($body){ //Line 8
$this->message = $body;
}Since you defined a constructor for your object, it's expecting you to pass to it the one parameter defined in its signature ($body). Even if you
didn't define your own constructor, you'd still need to instantiate the object like so:
$mess =& new Message();Object creation
always invokes an object constructor, which, in turn, is a function. Since it's a function, you need the parentheses.
The next line follows the same train of thought from the previous mistake. Your body() function merely returns a value. It doesn't set the $message member of the object. So, trying to use it in that context doesn't make sense. Instead, you'll need to write what's commonly called a 'setter' function to go along with your 'getter' function. Together, they'd look something like this:
function getMessage()
{
return $this->message;
}
function setMessage($message)
{
$this->message = $message;
}Using these within the client code would look like:
$myMessage = "Welcome to Rapture";
$welcome =& new Message($myMessage);
echo "$welcome->getMessage()";
$welcome->setMessage("Don't let the Big Daddy's get you");
echo "$welcome->getMessage()";Finally, if you're serious about trying OOP with PHP, you should really update to PHP 5. I cannot stress how much better its OOP capabilities are.