specifying home dir

Reply

Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

specifying home dir

 
0
  #1
Nov 30th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 166
Reputation: Lafinboy is an unknown quantity at this point 
Solved Threads: 7
Lafinboy's Avatar
Lafinboy Lafinboy is offline Offline
Junior Poster

Re: specifying home dir

 
0
  #2
Nov 30th, 2005
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]
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 ::

Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 80
Reputation: Daishi is an unknown quantity at this point 
Solved Threads: 2
Daishi Daishi is offline Offline
Junior Poster in Training

Re: specifying home dir

 
0
  #3
Nov 30th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: specifying home dir

 
0
  #4
Nov 30th, 2005
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
The reason I did it that way was because I can easily go type the following in SSH and it works just fine
  1. ls ~
so it's not which user, the tilde... (at least as I understand it) searches your OWN home dir so there is no need to specify which user at least on the servers I am working on
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: specifying home dir

 
0
  #5
Nov 30th, 2005
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
I was really trying to having to avoid doing the absoluate path, even though I know I could call on $_SERVER to generate the path for me in the example you gave. So is there no way to specify your own home dir in PHP?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1977 | Replies: 4
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC