Is there actually Document Root alternatives?

Status
Not open for further replies.

caftpx10

Well-Known Member
Messages
1,534
Reaction score
114
Points
63
I have created a simple script which outputs the results of all three document "root" results.
http://andreca.tk/dirtest/
As you can see, Document root 2 and 3 outputs the same thing, unlike document root 1.

So why was it said to try using __DIR__ if it isn't replicating the same result as the "original"?
Maybe using a superglobal variable (forgot the type) and string replacing the result can help end up with just the document root?

I'm currently trying to fix my script regarding errors just appearing which I have now solved, the only remaining issue is that require_once() doesn't work with either of the things used on that test script which I have linked too above.

The error exactly?:
Code:
[22-Oct-2014 12:52:27 America/New_York] PHP Fatal error:  require_once(): Failed opening required '/home/pscoolap/public_html/sesslogin/main/sesslogin/config.php' (include_path='.:/opt/alt/php54/usr/share/pear:/opt/alt/php54/usr/share/php') in /home/pscoolap/public_html/sesslogin/main/index.php on line 2
Same error for every "alternative".
I have noticed duplicate directories in these errors.

If the output from Document Root 1 outputs the thing that we are wanting then could there be more to it, but I have no idea what it could be.

It would be awesome if someone could point out what they think or what is going on here.


Workaround: Still use $_SERVER['DOCUMENT_ROOT'] but string replace the duplicating directories shown in the error.
This is an example of part of my code (which I have altered even more after coding this):
PHP:
str_replace('/sesslogin/sesslogin','/sesslogin',$_SERVER['DOCUMENT_ROOT'])
 
Last edited:

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
The superglobal is actually correct on xo2
 

caftpx10

Well-Known Member
Messages
1,534
Reaction score
114
Points
63
When was this? I think it wasn't working properly a few hours ago while trying to get my scripts to work (it suddenly broke for some strange reason), I had to do some large adjustments here and there.

Without the string replace, the main page would just be blank because of the directory path being repeated for an unknown reason causing a PHP error being logged.

Be aware that the error posted here was when I was trying out something else instead of document root 1, which just repeated the sesslogin directory.
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
So--it's doing something different now that it was before?
 

caftpx10

Well-Known Member
Messages
1,534
Reaction score
114
Points
63
It is now working without the workaround, the fix could've been applied hours later.
 
Status
Not open for further replies.
Top