demosthenes.info

I’m Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with , and . To receive more information, including news, updates, and tips, you should follow me on Twitter or add me on Google+.

web developer guide

my books

Book cover of Pro CSS3 AnimationPro CSS3 Animation, Apress, 2013

my projects

A Sass color keyword system for designers. Replaces CSS defaults with improved hues and more memorable, relevant color names.

CSSslidy: an auto-generated #RWD image slider. 3.8K of JS, no JQuery. Drop in images, add a line of CSS. Done.

tipster.ioAutomatically provides local tipping customs and percentages for services anywhere.

How To Avoid Problems In PHP

php / introduction

Estimated reading time: 1 minute, 15 seconds

  1. Don’t try to do everything at once. Write a little bit of code, then test it. Write a little bit more, and test it again. Don’t start writing a full page of code and expect it to run. When errors happen, it’s a lot easier to solve them if you know where they are happening.

  2. Put comment “traffic cones” in your code to narrow down problem areas. Comments in PHP are exactly the same as those in CSS: i.e.

    <?php This code will be run;
    /* this code will be ignored (multiple lines) */
    // this code (a single line) will be ignored too
    # this code (again on a single line) will also be ignored
    ?>

    If you are taking a class with me, I will not respond to cries of “it doesn’t work”. Before I can help you I expect you to tell me where the code doesn’t work, by eliminating suspect code inside comments. In doing so, you’re likely to find the cause of the problem yourself.

    Keep in mind that the PHP parser is sometimes inaccurate when reporting the locations of errors. Sometimes it will report “Error on line 1” when the error isn’t on line 1 at all (in fact this error usually indicates that a brace has not been closed correctly).

  3. Close code correctly. Problems coding HTML are usually due to incorrectly written tags and incorrectly closed tags. If this is the source of most of your errors in HTML, the same problems will continue to haunt you when coding PHP.

comments powered by Disqus

This site helps millions of visitors while remaining ad-free. For less than the price of a cup of coffee, you can help pay for bandwidth and server costs while encouraging further articles.