PHP 5/MySQL Programming- P18:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 63 Code Style The PHP processor ignores the spaces and carriage returns in your PHP code so you might wonder if it matters to pay such attention to how code is indented where the braces go and so on. While the PHP processor doesn t care how you format your code human readers do. Programmers have passionate arguments about how you should format your code. If writing code with a group for instance in a large project or for a class you are usually given a style guide you are expected to follow. When working on your own the specific style you adopt is not as important as being consistent in your coding. The particular stylistic conventions I adopted for this book are reasonably common relatively readable and easily adapted to a number of languages. If you don t have your own programming style the one in this book is a good starting place. However if your team leader or teacher requires another style adapt to it. Regardless of the specific style guidelines you use it makes lots of sense to indent your code place comments liberally throughout your program and use whitespace to make your programs easier to read and debug. Do not put a semicolon at the end of the if line. The following code prints we must be near a black hole. if day night print we must be near a black hole end if When the processor sees the semicolon following day night it thinks there is no code to evaluate if the condition is true. The condition is effectively ignored. Essentially the braces indicate that an entire group of lines are to be treated as one structure and that structure is part of the current logical line. Chapter 3 Controlling Your Code ith Conditions and Functions Working ith Negative Results The Ace program shows how to write code that handles a condition. Much of the time you want the program to do one thing if the condition is true and something else if it s false. Most languages include a special variant of the if statement to handle exactly this type of contingency. 64 PHP 5 MySQL .