| 
	
 | 
 Posted by J.O. Aho on 06/16/38 11:52 
Sukalyan wrote: 
> Hi! 
>    I have a problem when i go for include any page. 
>    I am trying to explane that 
>  
>  1. let, I am working under a folder 'www' 
>  
> 2. under that 2 folder and 1 file. 
>        folder's are  say 'abc', 'include' 
>        file is 'index.php' 
>  
> 3. under 'abc' has one file say 'index.php' 
>  
> 4. under 'include' has 4 file whose are included correctly with 
> 'index.php' under 'www' 
> 5. when I try to include that with 'index.php' under 'abc' I need to 
> change every link within 'include' header file or rewrite a new header 
> file for 'abc' folder 
>  
> is it possible that just changing index file of 'abc' include location 
> work correctly. 
 
When you include something without the full path in PHP, it's always the main  
page relation to other files that you have to think of. 
 
If file include/1.php includes file include/2.php, you have to use the full  
path: include('/var/www/html/main/include/2.php'); 
 
Better can be to let the index files to include things, so for index.php it  
would be: 
include('include/1.php'); 
include('include/2.php'); 
include('include/3.php'); 
include('include/4.php'); 
 
in abc/index.php it would be: 
include('../include/1.php'); 
include('../include/2.php'); 
include('../include/3.php'); 
include('../include/4.php'); 
 
another easy way to fix the paths is to use symlinks (some quite bad operating  
systems don't have filesystems that supports symlinks). 
 
cd abc 
ln -s ../include 
 
then you would have in abc: 
file: index.php 
symlink: include 
 
and now you could have the same relative paths in both index.php. 
 
 
  //Aho
 
  
Navigation:
[Reply to this message] 
 |