Reusable modules are key
When you create dynamic Web sites, you should use reusable modules, usually done by functions and include files. By forcing your code into modules, you can decrease the complexity of your code. Most experienced programmers already know this, but many overlook the importance of modularity when it comes to Web sites. Any time you find yourself using the same technique more than once, consider making a function for it, as in the following PHP example:
|
The scope of the $var
variable is the name
function. Before you can reference global variables in a function in PHP, you need to use the global keyword to define them. If a function will only be used on one page, you can simply include it in the same script that will reference the function. If more than one script will use this function, consider putting it in a separate file that can be imported by any script.
View Personalized Web sites in a jiffy Discussion
Page: 1 2 3 4 5 6 7 Next Page: Create your database