HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

PHP Help

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#36234 (In Topic #8152)
Joe
Avatar

Honoured member

Say if we have a test.php file in a sub-sub-directory under the root, and we tell it to include a file in the actual root. How would I do this?

I've asked this question numerous places, but everyone keeps giving me the same reply, which doesn't work. I've tried:

require_once($_SERVER['HTTP_HOST']."/global.php");
require_once($_SERVER['DOCUMENT_ROOT']."/global.php");
include('./global.php');
include('/global.php');
include('global.php');

…etc.

Back to the top
 
Posted
Rating:
#36235
Joe
Avatar

Honoured member

Also, including URL's doesn't work - I've tried. :(

Back to the top
 
Posted
Rating:
#36236
Joe
Avatar

Honoured member


Back to the top
 
Posted
Rating:
#36240
Avatar

Hallowed customer

This is some thing I have been having trouble with on a mod I am making.

I run Otaku Play Ground and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#36241
Avatar

ocStaff (admin)

The official way that usually works…

Code

$script_dir=dirname($_SERVER['SCRIPT_NAME']);

However at ocProducts we've had our script run on so many servers with faulty PHP versions or bizarre configurations, that we've had to take a different approach. Look at what we do in our index.php files.



Become a fan of ocPortal on Facebook or add me as a friend.

Expand: Was I helpful? Was I helpful?

Expand: Follow me on Twitter Follow me on Twitter







If I answered something that you think should be in the documentation, please take the initiative and add it to the community documentation. We really need people to help out here and build a well-organised large support resource.
Back to the top
 
Posted
Rating:
#36244
Avatar

Hallowed customer

I will try that.
Thanks.

I run Otaku Play Ground and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#36245
Joe
Avatar

Honoured member

I'm still a little confused, mainly because I'm not any good with PHP. Perhaps some detailed information?

Back to the top
 
Posted
Rating:
#36366
Avatar

Hallowed customer

I am not sure how to explain it.

I run Otaku Play Ground and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#36393
Avatar

Community saint

Code

<?php include('file_name.php'); ?>
So, if you had your document root like:

/var/www/htdocs

and you want /var/www/htdocs/include_me.php included with /var/www/htdocs/sub_1/sub_2/some_file.php, then /var/www/htdocs/sub_1/sub_2/some_file.php would contain:

Code

<?php include('../../include_me.php'); ?>
or

Code

<?php include('/var/www/htdocs/include_me.php'); ?>

 

"no violence, no hate, no pain, no enemies
just peace, unity, tolerance and love" - The Beloved

OCP V7 | Advocating monetary reform - FreeOurMoney

Need OCP friendly hosting? Look no further:
Web Hosting, Reseller Hosting, and Dedicated Servers w/cPanel - Elief! - Official hosting partner for ocPortal.
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: