- Joined
- Jul 4, 2004
- Messages
- 211
- Reaction score
- 0
I am designing a website in PHP atm and i have several different files that use functions from one another, as well as some veriables used in all of them. The current file structure goes as follows:
Index.php - This file just has the theme, and includes "includes.php"
-----Includes.php - This file includes: "functions.php","accounts.php","news.php","db.php", and puts it all togeather ( basically index.php without the theme... ), also this file contains the global veriables needed throughout all of the files, such as $ip ( so i dont have to keep redefining it in each file i use it in ), $debug, etc.
Then we have the files with the functions in them that includes calls:
Functions.php
accounts.php
db.php
news.php
When i stick the veriables needed in all of the files into a config.php file, and include them the veriables dont go into the functions, such as if i have:
I was thinking of moving the entire site to OOP and make them all create an instance of class config or extend class config, but i dont know if that will work or not.
Also, if i am to make it OOP, how do i go about doing that?
And finally: does it make a different in the config, for the veriables to carrie over into the functions when included if i make their name:
Thanks.
Index.php - This file just has the theme, and includes "includes.php"
-----Includes.php - This file includes: "functions.php","accounts.php","news.php","db.php", and puts it all togeather ( basically index.php without the theme... ), also this file contains the global veriables needed throughout all of the files, such as $ip ( so i dont have to keep redefining it in each file i use it in ), $debug, etc.
Then we have the files with the functions in them that includes calls:
Functions.php
accounts.php
db.php
news.php
When i stick the veriables needed in all of the files into a config.php file, and include them the veriables dont go into the functions, such as if i have:
PHP:
<?php
include("config.php");
echo $ip; // this will print the IP.
function whatever()
{
echo $ip; // This will print nothing, its blank, or if i do echo "IP: $ip" or echo "IP: " . $ip; it prints just IP:
}
?>
I was thinking of moving the entire site to OOP and make them all create an instance of class config or extend class config, but i dont know if that will work or not.
Also, if i am to make it OOP, how do i go about doing that?
And finally: does it make a different in the config, for the veriables to carrie over into the functions when included if i make their name:
PHP:
var $ip = $_SERVER['REMOTE_ADDR'];
//compared to
$ip = $_SERVER['REMOTE_ADDR']; // ( how i have it now )
Thanks.

