Lately, I have been trying to create "good" code - mind the trying 🙂
Referring to the article of Tim (http://www.phpbuilder.com/columns/tim20001010.php3?&print_mode=1) on this site, I have a couple of questions which I have to deal with for my site too.
Concerning the example code :
1) I suppose the html_lib is ment to be included in an other php script (require()). If the other page already required bug_data.php, you get an error. What is the best practice to avoid this? Never use include of other libs in a lib? (in my case, I have a lib for databases (database_lib.php)and one with several classes, which need this database_lib.php.) Where to use include()?
2) Returning the $error. If you return false, it would be wise to return the type of error too. Tim does so by setting the $errormessage global. However, if the function where the $errormessage is set, is called by an other function (eg process_form_results()), that function will not be able to read $errormessage. Good programming cannot require you to global different variabeles when you call a function, can it? How can I solve this problem? Just returning the $errormessage will not evaluate as false off course...
Can anybody give me an answer or point me to a website which might help me? Thx!