Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>My experience with PHP has taught me a few things. To name a few:</p> <ul> <li>Always output errors. These are the first two lines of my typical project (in development mode):</li> </ul> <pre><code>ini_set('display_errors', '1'); error_reporting(E_ALL);</code></pre> <ul> <li><p>Never use <em>automagic</em>. Stuff like autoLoad may bite you in the future.</p></li> <li><p>Always require dependent classes using <code>require_once</code>. That way you can be sure you'll have your dependencies straight.</p></li> <li><p>Use <code>if(isset($array[$key]))</code> instead of <code>if($array[$key])</code>. The second will raise a warning if the key isn't defined.</p></li> <li><p>When defining variables (even with <code>for</code> cycles) give them verbose names (<code>$listIndex</code> instead of <code>$j</code>)</p></li> <li><p>Comment, comment, comment. If a particular snippet of code doesn't seem obvious, leave a comment. Later on you might need to review it and might not remember what it's purpose is.</p></li> </ul> <p>Other than that, class, function and variable naming conventions are up to you and your team. Lately I've been using <a href="http://framework.zend.com/manual/en/coding-standard.naming-conventions.html" rel="noreferrer">Zend Framework's naming conventions</a> because they feel right to me.</p> <p>Also, and when in development mode, I set an error handler that will output an error page at the slightest error (even warnings), giving me the <a href="http://pt2.php.net/manual/en/function.debug-backtrace.php" rel="noreferrer">full backtrace</a>.</p>
 

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