Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>You are doing it wrong <sup>tm</sup></strong></p> <ol> <li><p>You should be utilizing an autoloader, instead of including files with each class manually. You should learn about <a href="http://php.net/manual/en/function.spl-autoload-register.php" rel="noreferrer"><code>spl_autoload_register()</code></a> and and <a href="http://php.net/manual/en/language.namespaces.php" rel="noreferrer">namespaces</a>, and how to utilize both of them.</p></li> <li><p>Do not generate output in the <code>__construct()</code> methods. That's an extremely bad practice</p></li> <li><p>The variables are still there. That is not the problem. In PHP, when you extend a <strong>class</strong>, it <strong>does not inherit the constructor</strong>. </p></li> <li><p>You do not understand how inheritance works. When you call method on instance of extended class <strong>it will not execute parent class's method , before calling extended class's methods</strong>. They get overwritten , not stacked.</p></li> <li><p>Object variables should not be exposed. You are breaking the encapsulation. Instead og defining them as <code>public</code> you should use <code>protected</code>.</p></li> <li><p>You should extend classes of they are different type same general thing. The <code>extends</code> in PHP means <strong>is-a</strong>. Which means that, when you write <code>class Oak extends Tree</code>, you mean that all the oaks are trees. The same rule would mean, that in your understanding all <code>Property</code> instances are just a special case of <code>Core</code> instances. Which they clearly ain't.</p> <p>In OOP, we have principle. One of which is <a href="http://en.wikipedia.org/wiki/Liskov_substitution_principle" rel="noreferrer">Liskov substitution principle</a> (shorter <a href="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/07/liskov_substitution_principle_small.jpg" rel="noreferrer">explanation</a>). And this is the thing your classes are violating.</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload