steva
asked on
PHP path reference for ../
What determines how PHP evaluates things like
include( ../file.html);
My experience is that this is normally evaluated with respect to the location of the script that contains the line but I've come across a situation where it's being evaluated with respect to an absolute address. How do you tell PHP to evaluate these with respect to some absolute address?
Thanks for any info.
Steve
include( ../file.html);
My experience is that this is normally evaluated with respect to the location of the script that contains the line but I've come across a situation where it's being evaluated with respect to an absolute address. How do you tell PHP to evaluate these with respect to some absolute address?
Thanks for any info.
Steve
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That's from 'php.ini'. 'include path' is where PHP looks if the file is Not found in the specified place.
http://php.net/manual/en/function.include.php
http://php.net/manual/en/function.include.php
ASKER
But in my case PHP is finding a way to resolve the ../ without using the current directory or what's in the include_path. The full directory involved is
When the include(../config.php) in uploader_settings.php is evaluated, the circled config.php comes in. Somehow CodeIgniter has inserted its own path so that the ci folder - the top of the CodeIgniter stuff - is the reference for evaluating ../.
This will probably become clearer after studying more about CodeIgniter. I'm just surprised that it can do anything that overrides the basic PHP path evaluation.
When the include(../config.php) in uploader_settings.php is evaluated, the circled config.php comes in. Somehow CodeIgniter has inserted its own path so that the ci folder - the top of the CodeIgniter stuff - is the reference for evaluating ../.
This will probably become clearer after studying more about CodeIgniter. I'm just surprised that it can do anything that overrides the basic PHP path evaluation.
"PHP path evaluation"?? PHP uses the path structures, directories and files, of the underlying operating system.
In addition, " include path=.:/usr/share/php:/usr /share/pea r" are places that you can't put any files normally (unless you get 'root' access on the server).
If you want the 'config.php' in the same directory, that what you put: include(config.php);
In addition, " include path=.:/usr/share/php:/usr
If you want the 'config.php' in the same directory, that what you put: include(config.php);
ASKER
Yeah. I don't know. Basically I don't understand how the include(../config.php) in uploader_settings.php above loaded the config.php circled in the figure above. I need to go deeper into CodeIgniter to understand what going on..
Cheers
Cheers
Are you seeing this on your own computer or on your web hosting?
ASKER
Web hosting, on a Linux/Apache server. But it is doing what it should. It needs to load that particular config file that I've circled. That's where all the config options are for the upload operation it's doing. I just don't know how include(../config.php) from uploader_settings.php accomplishes that.
Have you done anything with CodeIgniter, or other PHP frameworks?
Have you done anything with CodeIgniter, or other PHP frameworks?
I generally avoid frameworks like the plague. It's difficult enough without some program pretending it knows better than you. While I'm sure they are useful for the things they are intended for, I have no idea what that might be.
I especially would not run any IDEs that provide their own 'web server' because your actual web hosting is always going to be somewhat different. I have at least 3 versions of Apache and 3 versions of IIS that I have dealt with. Add to that 3 or 4 versions of PHP and MySQL and MS SQL, I can't have my development situation limited to what only one IDE can provide.
I especially would not run any IDEs that provide their own 'web server' because your actual web hosting is always going to be somewhat different. I have at least 3 versions of Apache and 3 versions of IIS that I have dealt with. Add to that 3 or 4 versions of PHP and MySQL and MS SQL, I can't have my development situation limited to what only one IDE can provide.
ASKER
I generally avoid frameworks like the plague. It's difficult enough without some program pretending it knows better than you. While I'm sure they are useful for the things they are intended for, I have no idea what that might be.That was pretty much my opinion, until some code was dropped in my lap that I had to understand and it used CodeIgniter, so I was dragged kicking and screaming to it.
But it's not bad! Basically you get "professional" code that does the things that are typically wily in PHP (database, security, login, sessions, file uploads, image manipulation . . .) and your finished pages aren't a godawful mixture of PHP, HTML and database code. If you have 32 minutes you might find this video - "CodeIgniter from Scratch" - interesting: http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-day-1/
But I almost specialize in fixing "godawful mixtures of PHP, HTML and database code". That's where I make my money on the web. I have 'undone' Dreamweaver, Adobe Go Live, Microsoft Publisher and Front Page, and Apple's iWeb to make them work. There are several that I won't touch such as Smarty templates, Xoops, and NetObjects Fusion. While they may be well organized, they are complicated beasts and not worth my effort to understand and fix.
ASKER
OK, then it's probably not for you. I make my money on the web building things for people, and to me it looks like it might replace the hammer in my toolbox with a nail gun - so I'm interested.
ASKER
I think my issues are with the CodeIgniter framework I'm working in. I'm trying to make sense of this from a PHP view but CodeIgniter seems to be doing something above PHP on its own.
A file has
require('../config.php');
and if I insert code in that file to display the results of get_include_path() I see:
include path=.:/usr/share/php:/usr
But config.php is actually being pulled relative to the top codeigniter directory, i.e., up one from ci and down to the config.php there.
Thanks for your input, though.
Steve