Developer Forums | About Us | Site Map
Search  
HOME > TUTORIALS > SERVER SIDE CODING > PHP TUTORIALS > PERSONALIZED WEB SITES IN A JIFFY


Sponsors





Useful Lists

Web Host
site hosted by netplex

Online Manuals

Personalized Web sites in a jiffy
By Steve Fox - 2004-02-02 Page:  1 2 3 4 5 6 7

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:

function name ($var) { // code goes here }

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

First published by IBM developerWorks


Copyright 2004-2017 GrindingGears.com. All rights reserved.
Article copyright and all rights retained by the author.