| | |
specifying home dir
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
I am trying to create a script and I want to be able to say [php]require "~/functions/functions1.php";
require "~/functions/functions2.php";
require "~/functions/functions3.php";[/php]
but php doesn't seem to understand what the tilde means (and yes this for a linux server). Is there any way I can specify the home dir without actually having to point it to to absolute path? A relative path wouldn't work because I won't know how many folders some of these files will be in
require "~/functions/functions2.php";
require "~/functions/functions3.php";[/php]
but php doesn't seem to understand what the tilde means (and yes this for a linux server). Is there any way I can specify the home dir without actually having to point it to to absolute path? A relative path wouldn't work because I won't know how many folders some of these files will be in
One method would be to define a global var to hold the absolute path to the specified folder. You can then use the global var in the require function to build the path to the file required. Example:
[PHP]define('FUNCTION_PATH', 'http://127.0.0.1/devsite/functions/');
// the FUNCTION_PATH var can then be used like:
require(FUNCTION_PATH.'functions1.php');
require(FUNCTION_PATH.'functions2.php');
require(FUNCTION_PATH.'functions3.php');[/PHP]
[PHP]define('FUNCTION_PATH', 'http://127.0.0.1/devsite/functions/');
// the FUNCTION_PATH var can then be used like:
require(FUNCTION_PATH.'functions1.php');
require(FUNCTION_PATH.'functions2.php');
require(FUNCTION_PATH.'functions3.php');[/PHP]
If I've been a help please confirm by clicking the Add to Lafinboy's Reputation link in the header of this reply.
Lafinboy Productions
:: Website Design :: Website Development ::
Lafinboy Productions
:: Website Design :: Website Development ::
•
•
•
•
Originally Posted by Daishi
There are more than likely server configurations that are preventing you from accessing the file in ~/functions/. This is primarily due to security issues.
Also, you probably should specify which user's home directory you want to go from (i.e. ~johndoe/functions/).
-Fredric
PHP Syntax (Toggle Plain Text)
ls ~
•
•
•
•
Originally Posted by paradox814
I am trying to create a script and I want to be able to say [php]require "~/functions/functions1.php";
require "~/functions/functions2.php";
require "~/functions/functions3.php";[/php]
but php doesn't seem to understand what the tilde means (and yes this for a linux server). Is there any way I can specify the home dir without actually having to point it to to absolute path? A relative path wouldn't work because I won't know how many folders some of these files will be in
![]() |
Similar Threads
- package javax.ejb.* does not exist (Java)
- Problem with recursion in subdirectories (Shell Scripting)
- How to backup Outlook Express email folders and settings (Windows NT / 2000 / XP)
- Mandrake Linux is a &^%$ (*nix Software)
Other Threads in the PHP Forum
- Previous Thread: i need help, total newb here :)
- Next Thread: How to calculate previous date?
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error fcc file files folder form forms function functions google howtowriteathesis href htaccess html image images include insert integration ip java javascript joomla ldap limit link login loop mail menu methods mlm mod_rewrite multiple multipletables mysql oop open parse paypal pdf php problem query radio random recursion regex remote script search server sessions sms soap source space speed sql structure syntax system table template tutorial update upload url validation validator variable video web xml youtube





