Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Instead of that dreadful abomination, you should learn how to utilize <a href="http://uk.php.net/manual/en/function.spl-autoload-register.php" rel="nofollow noreferrer"><code>spl_autoload_register()</code></a>:</p> <pre><code>spl_autoload_register( function( $classname ){ $filename = 'inc/classes/' . $classname . '.class.php'; if ( !file_exists( $filename) ){ throw new Exception("Could not load class '$classname'.". "File '$filename' was not found !"); } require $filename; }); </code></pre> <p>And you should register the autoloader in your <code>index.php</code> or <code>bootstrap.php</code> file, and do it only once per loader (this ability lets you define multiple loaders, but that's used, when you have third party library, which has own autoloader .. like in case of SwiftMailer).</p> <p>P.S. please learn to use <strong>prepared statements</strong> with MySQLi or PDO.</p> <p><strong>Update</strong></p> <p>Since you are just now learning OOP, here are few things, which you might find useful:</p> <p>Lectures:</p> <ul> <li><a href="http://www.phpconference.co.uk/talk/advanced-oo-patterns" rel="nofollow noreferrer">Advanced OO Patterns</a></li> <li><a href="http://www.youtube.com/watch?v=4F72VULWFvc" rel="nofollow noreferrer">Inheritance, Polymorphism, &amp; Testing</a></li> <li><a href="http://www.youtube.com/watch?v=wmgnFbsaPvo" rel="nofollow noreferrer">Recognizing smelly code</a></li> <li><a href="http://www.youtube.com/watch?v=-FRm3VPhseI" rel="nofollow noreferrer">Global State and Singletons</a></li> <li><a href="http://www.youtube.com/watch?v=RlfLCWKxHJ0" rel="nofollow noreferrer">Don't Look For Things!</a></li> </ul> <p>Books:</p> <ul> <li><a href="http://rads.stackoverflow.com/amzn/click/1430210117" rel="nofollow noreferrer">PHP Object-Oriented Solutions</a></li> <li><a href="http://rads.stackoverflow.com/amzn/click/0321127420" rel="nofollow noreferrer">Patterns of Enterprise Application Architecture</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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