tags:

views:

174

answers:

3
<?php
 class Box
 {
   var $contents;

   function Box($contents) {
     $this-&gt;contents = $contents;
   }

   function get_whats_inside() {
     return $this-&gt;contents;
   }
 }

?>

I am going through a OO tutorial. I am familiar with PHP and the concept of OO but it is still an uphill struggle most of the time! However, the code above returns the error "Unexpected & on line 7". I cannot find anyone else having had problems with the tutorial. I am running MAMP with php version 5.2.5. Anyone have any ideas?

+5  A: 

It should read $this->contents instead of $this-&gt;contents

Vinko Vrsalovic
I really should learn to actually look at what is in front of me. Doy! Thanks
Drew
A: 

I guess it should be

$this->contents = $contents;
return $this->contents;

instead of

$this-&gt;contents = $contents;
return $this-&gt;contents;

Seems there was some HTML involved...

schnaader
A: 

Somehow your code has been HTML-encoded.

The "& gt;"s should be ">" symbols

Greg