Hudzilla.org - the homepage of Paul Hudson
Contents > Wish List | Report Bug | About Me ]

19     Writing PHP

This is NOT the latest copy of this book; click here for the latest version.

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: php_check_syntax()
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: Checking the PHP version with phpversion() and version_compare()
19.8. Debugging
19.8.1. What is a bug?
19.8.2. The most basic debugging technique: debug_zval_dump()
19.8.3. Making assertions: assert() and assert_options()
19.8.4. Triggering your own errors: trigger_error()
19.8.5. Source highlighting: highlight_file() and highlight_string()
19.8.6. Handling MySQL errors: mysql_error()
19.8.7. Exception handling
19.8.8. Backtracing your code: debug_backtrace()
19.8.9. Debuggers
19.8.10. Custom error handlers: set_error_handler(), restore_error_handler(), and error_log()
19.8.11. Custom exception handlers: set_exception_handler() and restore_exception_handler()
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: error_reporting()
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



<< 18.11 Next chapter   19.1 The design process >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
A PHP User - 04 Jul 2008

i especially like the concept of authentication real simple and genious
thanks guys
dani

A PHP User - 04 Jul 2008

11111111111111ttttttttttttttttttttt1111111111111111111ttttttttttttttt

A monkey using PHP - 04 Jul 2008

thank you very very much
this free book helps me out of the cage, that i become a real human never the uncivilized ape.
sorry that i grab your site. it blurry my eyes by reading them on screen.
but anyway...thank you...



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is six plus two?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow