How to put PHP class definition in include file
<p>I'm new to PHP, having trouble when I move a class definition out of my "main" page and into an include file.</p>

<p>Suppose I have main.php, with the below contents. It works fine:</p>

<pre><code>&lt;?php
class SimpleClass
{
    public $var = 'a def value';

    public function displayVar() {
        echo $this-&gt;var;
    }
}
?&gt;
&lt;html&gt;
&lt;h1&gt;blah blah blah&lt;/h1&gt;
&lt;/html&gt;
</code></pre>

<p>But now suppose that I try removing the class definition and putting it in a <strong>separate</strong> file, so that the main.htm now looks like:</p>

<pre><code>&lt;?php
include("classdef.php");
?&gt;
&lt;html&gt;
&lt;h1&gt;blah blah blah&lt;/h1&gt;
&lt;/html&gt;
</code></pre>

<p>and classdef.php is:</p>

<pre><code>&lt;?php
class SimpleClass
{
    public $var = 'a def value';

    public function displayVar() {
    echo $this-&gt;var;
}
?&gt;
</code></pre>

<p>Then when I view my main.php, it displays as</p>

<pre><code>var; } } ?&gt;
blah blah blah
</code></pre>

<p>As if the <code>&gt;</code> character in the <code>$this-&gt;var</code> is interpreted as closing the PHP. I've had trouble searching for this, in that I don't know what the <code>-&gt;</code> operator is called.</p>

<p>This is PHP 5.3.3 on Apache 2.2 on Windows.</p>
