![]() |
Includes are driving me nuts!!!
Im going to go insane figuring out a way to make these include files work. I finally get one directory to work, and then another one goes and doesn't work.
How do you guys work on your local machine?! Paths need to be relative to be able to transfer from one machine to another, and relative paths SUCK! Aside from include problems, where I can rest in peace by just adding a "../" for every directory I go down (it would be great if I didn't have to), I need to deal with these smarty problems. smarty_libs.php: PHP Code:
PHP Code:
------------------ index.php /include /smarty /templates /cache /config /compile smarty.class.php smarty_libs.php ------------------- Can somebody stop the headaches? I go down a directory and everything breaks. I can't do absolute paths from the root directory either. |
I wish I could remember who it was who suggest this, so I could give them credit, but have you tried using $_SERVER['DOCUMENT_ROOT']? I've started to employ this between my test machine and my remote server and it works quite well. Say if you're local is a windows box, and the document root is C:\my documents\htdocs, and your remote is linux, and it's /www/public_html, using document root, you never have to worry about relative paths, you just
include($_SERVER['DOCUMENT_ROOT'] . "/path/to/include.php"); It's just like using include("C:\my documents\htdocs\path\to\include.php"); or include("/www/public_html/path/to/include.php"); except that since you're calling the _SERVER array it will automagically fill in the root based on whatever machine you may transfer the script to. -m |
This is the problem:
PHP Code:
PHP Code:
And also, you need to change php.ini and include that dir.. If you need more detailed description, you could add me to MSN(PM me for my msn). |
I figured out a nicer way from delayedinsanity's.
PHP Code:
Edit: DONT USE THIS! :( It screws up any frameworks you might be using. |
Here's a suggestion:
in index.php (or what ever your bootstrap file is): Code:
define( 'ROOT_DIR', dirname(__FILE__));Code:
require_once ROOT_DIR . '/abcd/lib.php';Code:
define('ROOT_DIR', $_SERVER['DOCUMENT_ROOT'] . 'your_app_dir'); |
Whats a bootstrap file?
|
Quote:
Bootstrapping (computing) - Wikipedia, the free encyclopedia |
| All times are GMT. The time now is 06:28 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0