PHPBuilder - Switchbox Page 3



RSS Twitter
Articles Application Architecture

Switchbox - Page 3

by: Vic Fryzel
|
March 7, 2003

Using our SwitchBox is even easier as it only takes two lines of code to implement. Let's look at the code of index.php, and then I will explain it.

<?php
// Set switch
$switch "index";

// Call SwitchBox
require './includes/SwitchBox.php';

/* Follow with index.php's code */
?>
What's happening is simple. We set our switch (used by the SwitchBox so that the SwitchBox knows what to do), and then we call the SwitchBox. Depending on what $switch was, our SwitchBox takes the appropriate actions. In this case, our SwitchBox included the files 'fns_database.php' and 'fns_index.php'. After those two lines of code, the global variables in the SwitchBox, everything in fns_database.php, and everything in fns_index.php, are all available right on index.php. If you did not want to include any files for the page, you could simply leave the line:
$switch = "...";
out of the page. Then only the global variables would be available in the application.
Easy right? Ok so let's review...

« Previous Page
1
|
2
|
3
|
4
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Vic Fryzel

Comment:



Comment:

(Maximum characters: 1200). You have characters left.