Forum Moderators: coopster

Message Too Old, No Replies

What PATH is correct?

         

toplisek

9:36 pm on Feb 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have included file like:
include($_PATH1.".../myfile.php");
there is PATH defined in variable PATH1 with value:
$_PATH3=$_SERVER['DOCUMENT_ROOT']."/";

Why this works on server but not
$_PATH1="http://" . $_SERVER['SERVER_NAME']."/";

This shows (when echo my server value) and it is correct but include file is not seen...

Is there some global variable or info (php) element that defines what will be working for included files?

lokeshshettyk

10:29 am on Feb 5, 2009 (gmt 0)

10+ Year Member



Three options I suggest

1.
inlcude ("/rootfolder/subfolder/myfile.php");

2.
include ($_SERVER['DOCUMENT_ROOT'] . "/rootfolder/subfolder/myfile.php");

3.
include ("../../myfile.php");

Cheers :)

[edited by: lokeshshettyk at 11:09 am (utc) on Feb. 5, 2009]

toplisek

10:32 am on Feb 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why is $_PATH1="http://" . $_SERVER['SERVER_NAME']."/"; not working actually?

lokeshshettyk

11:08 am on Feb 5, 2009 (gmt 0)

10+ Year Member



Well, something for you to figure out, it works for me...

You may also try - $_PATH1="http://".$_SERVER['HTTP_HOST']."/";

Cheers :)

toplisek

1:40 pm on Feb 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi,
1. I have noticed that code works CSS file, images like:
<link rel="stylesheet" type="text/css" href="<?=$_PATH1 ?>css/styles.css" />
if I use $_PATH1="http://" . $_SERVER['HTTP_HOST']."/";

2. But include files do not work with this path. I should use
$_PATH=$_SERVER['DOCUMENT_ROOT']."/";

In this way it will not be seen path of server files. When I use this path for images it will be seen file path on server which is not correct way.

do you have any idea why it gives issue when I use point number 1 for INCLUDE files? Strange behaviour for included files...It worked on old server (old PHP version).

Need urgent help.

g1smd

3:16 pm on Feb 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As I often haven't got access to the php.ini file on the server, I use .htaccsss to specify the PHP include path; using something like:

php_value include_path /vhost/host4/e/x/1/example.co.uk/www/includes

toplisek

3:25 pm on Feb 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In my example how would you define $_PATH1?
Maybe is also very important that folders are all lower characters.
I have noticed that some issue is also with this. Like using en-GB as folder will not be recognised...but en-gb will be.

toplisek

7:03 am on Feb 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi,
I have code sample like:
$dir1 = '/en-GB/bla/blah';
$dir2 = '/classes/class1';
set_include_path($dir1.';'.$dir2.';'.get_include_path());

How to implement via get_include_path? need help

toplisek

2:15 pm on Feb 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have triied to include file with your code like:
$dir1 = '/en-GB/bla/blah';
set_include_path($dir1 . PATH_SEPARATOR . get_include_path());
include('file.php');

It does not include my file.