php quicky

Associate
Joined
26 Jan 2006
Posts
1,502
Hey guys,

in php, how I write paths to be universal to all servers?

I know "./test.php" is supposed to look in the same directoy for the file? right? How about if the file is the third parent or etc?

Thanks.
 
In PHP you can use

$_SERVER['DOCUMENT_ROOT']

Or alternatively,

../ to go the parent directory, which you can use several together

eg

../../../ will take you three levels up
../images/ will be the folder called "images" in the parent directory etc.
 
thanks all work :)

However, if you can help with another problem I try to solve please do so.

I have an <?include> statement in my HTML doc which does some stuff, but if it fails I try to redirect to another page using header(). But I get headers already out errors. Any workaround for this?

Thanks
 
drak3 said:
I have an <?include> statement in my HTML doc which does some stuff, but if it fails I try to redirect to another page using header(). But I get headers already out errors. Any workaround for this?
Quickest workaround is to use output buffering i.e.
Code:
<?php
ob_start();
?>

// Do stuff here inc. header() calls.

<?php
ob_end_flush();
?>
 
Back
Top Bottom