Entrepreneur
BANNED
- Oct 12, 2007
- 439
- 391
What it is, is i have a large site built in php and i'm converting it to a MySQL based CMS, to enable updating and moving it easier.
The path to my includes is specified in all my files, but while buidling a config file i decided, as i'm moving server, to add the path to an include within the config, then within all my php files access this path within that include. Therefore if the server changes again in the future, i edit 1 line in 1 file and not a shed load in many files.
What i did was create my config.inc.php file as below:
Then in all my files i include the above file first, and have the file itself within the public directory so doesn't require a path itself,
and then for any includes within say, the aboutus.php i use the include path from the config file as below.
This actually works perfectly, but it suddenly dawned upon me that, and this is probably because i'm crap at php, that when php does what it does, it would appear as below.
This obviously has no quotes or anything around it?
Is this an issue, should i be doing this in a different way, because although it works on my home computer/server test bed thing (running Apache, PHP and MySQL) i worry that this is incorrect and the tolerant language that is php is letting it slide?
As always, i go on, but help or a knowledgable answer would please me massively. Thanks.
The path to my includes is specified in all my files, but while buidling a config file i decided, as i'm moving server, to add the path to an include within the config, then within all my php files access this path within that include. Therefore if the server changes again in the future, i edit 1 line in 1 file and not a shed load in many files.
What i did was create my config.inc.php file as below:
Code:
<?php
define('INCLUDE_PATH' , '/server/path/to/includes/');
?>
Then in all my files i include the above file first, and have the file itself within the public directory so doesn't require a path itself,
Code:
<?php
require_once 'config.inc.php';
?>
and then for any includes within say, the aboutus.php i use the include path from the config file as below.
Code:
<?php
include INCLUDE_PATH . "header.inc.php";
?>
This actually works perfectly, but it suddenly dawned upon me that, and this is probably because i'm crap at php, that when php does what it does, it would appear as below.
Code:
<?php
include /server/path/to/includes/header.inc.php;
?>
This obviously has no quotes or anything around it?
Is this an issue, should i be doing this in a different way, because although it works on my home computer/server test bed thing (running Apache, PHP and MySQL) i worry that this is incorrect and the tolerant language that is php is letting it slide?
As always, i go on, but help or a knowledgable answer would please me massively. Thanks.