Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What are your coding standards?</p> <p>It’s common to start class names with a capital letter (for example: <code>class MyClass</code>). If you do this, then it follows that you would name the file <code>MyClass.php</code>. And <code>MyClass.class.php</code> works too.</p> <p><code>MyClass.class</code> is a bad idea that could allow someone to view your source code if they request that file by name. Using the <code>.php</code> extension ensures that the the user will only see the output after the file is processed by the PHP interpreter which—for a file that contains nothing but a class—is a blank page.</p> <p>Finally, look into <a href="http://us.php.net/manual/en/language.oop5.autoload.php" rel="noreferrer"><code>autoload()</code></a>, which saves you the trouble of calling <code>require_once</code> in order to load your class.</p> <hr> <p><strong>Update:</strong> With PHP coding standard <a href="http://www.php-fig.org/psr/psr-4/" rel="noreferrer">PSR-4</a>, there is now a semi-official way to name your class files. The previous advice—to name your class file the same as the class with the <code>.php</code> extension—still stands. But now you are expected to place that class file in a subdirectory named after your class namespace; PSR-4 requires that all of your classes be contained in a namespace defined by you.</p> <p>What do you get for this? Autoloading for free! If you’re using <a href="http://getcomposer.org/" rel="noreferrer">Composer</a>, you can <a href="https://getcomposer.org/doc/01-basic-usage.md#autoloading" rel="noreferrer">specify the top-level directory for your classes</a> and Composer will autoload them. No more <code>require</code> statements to load your classes.</p> <p>If you don’t want to do this, you don’t have to: PSR-4 is a <em>recommendation</em>, not a requirement.</p>
    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. 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