Writing PHP
While it is almost certain that you read this book to learn the PHP programming language, I believe that there is a lot more to learning a language than just memorising its syntax and functions. For example, learning to program to a fixed style means your code will be easier to maintain by yourself and by others, and learning to debug properly means your code will have fewer bugs and you will have fewer headaches.
This chapter is designed to fill you in on the practical aspects of being a PHP programmer, and should hopefully make your programming life easier, as well as help you find and solve problems with the minimum of fuss.
The topics covered in this chapter are:
-
How to analyse your system requirements
-
Using a development tool to help you code
-
File layout schemes and group development
-
Documentation and testing
-
Distribution your code and licensing your work
-
How to debug your scripts
-
Troubleshooting hints and tips
-
Where to get help if you still have a problem
Chapter contents
- 19.1. The design process
- 19.1.1. Analysing the requirements
- 19.1.2. Designing the solution
- 19.1.3. Developing the code
- 19.1.4. Implementing the application
- 19.1.5. Maintenance and support
- 19.2. Which IDEs are good
- 19.2.1. Line numbering
- 19.2.2. Syntax highlighting
- 19.2.3. Online help
- 19.2.4. Code insight
- 19.2.5. Interactive debugging
- 19.2.6. Profiling
- 19.2.7. Popular IDEs
- 19.3. Laying out your files
- 19.3.1. Directory structuring
- 19.4. Group development
- 19.4.1. How to develop code
- 19.4.2. Version control
- 19.5. Documenting your project
- 19.6. Testing
- 19.7. Distributing your code
- 19.7.1. Charging for your work
- 19.7.2. PHP Encoders
- 19.7.3. Cross-platform code 1: Loading extensions
- 19.7.4. Cross-platform code 2: Using extensions
- 19.7.5. Cross-platform code 3: Path and line separators
- 19.7.6. Cross-platform code 4: Coping with php.ini differences
- 19.7.7. Cross-platform code 5
- 19.8. Debugging
- 19.8.1. What is a bug?
- 19.8.2. The most basic debugging technique
- 19.8.3. Making assertions
- 19.8.4. Triggering your own errors
- 19.8.5. Source highlighting
- 19.8.6. Handling MySQL errors
- 19.8.7. Exception handling
- 19.8.8. Backtracing your code
- 19.8.9. Debuggers
- 19.8.10. Custom error handlers
- 19.8.11. Custom exception handlers
- 19.8.12. Using @ to disable errors
- 19.8.13. phpinfo()
- 19.9. Debugging practice
- 19.10. Coding style
- 19.10.1. Comments and whitespace
- 19.10.2. Variable naming
- 19.10.3. Functions
- 19.10.4. Distinguishing code blocks
- 19.11. Output style
- 19.11.1. Options for Tidy
- 19.12. Troubleshooting
- 19.12.1. Error types
- 19.12.2. Choosing what types of errors you see
- 19.12.3. Common errors
- 19.13. Getting Help
- 19.13.1. The documentation
- 19.13.2. Mailing lists
- 19.13.3. Websites
- 19.13.4. IRC
- 19.13.5. Conferences
- 19.13.6. User groups
- 19.13.7. Submitting a bug
- 19.13.8. Contacting the author
- 19.14. Getting qualified
- 19.15. Summary
- 19.16. Exercises
- 19.17. Further reading
- 19.18. Next chapter



Copyright 2012 Future Publishing Limited (company
registered number 2008885), a company registered
in England and Wales whose registered office is at
Beauford Court, 30 Monmouth Street, Bath, BA1 2BW, UK