NAVIGATION:

 

SUPPORTERS:

FlashComponents
  Flash Templates
  Flash Gallery
  Flash Slideshow
  Flash Menu
  Flash Design
  Flash Video
  User Interface

 

FOLLOW:

RSS it down! Twitter it up! Facebook it like a fiend!

 

 

 

 

 
Using Includes with PHP
         by Jubba

Introduction
This tutorial is just a down and dirty explanation on how to use the include() function in an attempt to make your PHP code-writing life a little easier. Basically the include() function includes the file placed inside the parenthesis as the argument inside of your main file. I use this a lot when I am connecting to a database over multiple files. I keep all of my connection variables in my include file and call them throughout my main scripts. Kind of like this:

Include file: include.php
<?
// This is my include file
$dbHost = "localhost";
$dbUser = "root";
$dbPass = "";
$dbName = "MyDataBase";
?>

This is the file that I name include.php Its the one that I will be placing inside of my main scripting files. Then all you need to do to place your information inside of your file is one small line of code:

Main file:
<?
include("include.inc");
// The rest of my code would go here...
// and here...
// and here...
// and here...
// and here...
?>

Now there is another function similar to this, require() the only difference between them is that require() returns a fatal error and stops the script from executing. Include() doesn't do that; the script continues to run even if the file that you are including contains some type of an error. I know that this tutorial didn't cover 100% of the bases. It was just a simple explanation. If you would like more info you can check out PHP.net or feel free to ask on the forums in the Server-side Scripting Forum.

Jubba

 

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)