CHAPTER 5 – One Script per Function

Another alternative is the one script per function approach. Here, there is no driver script like in the previous section, but each function is stored in a dif- ferent script and accessed through its URL (for example, about.php, where in the previous example, we had index.php?page=about). Both styles have pros and cons; in the "one script serves all" method, you only have to include the basics (like session handling, connecting to a database) in one script, while with this method, you have to do that in each script that implements the func- tionality. On the other hand, a monolithic script is often harder to maintain (because you have to dig through more files to find your problem). Of course, it's always up to you, the programmer, to make decisions regarding the layout of your application. The only real advice that we can give is that you always need to think before you implement. It helps to sit down and brainstorm about how to lay out your code.

Post Comment
Login to post comments