|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34514 __FILE__ gives relative path if not in web root
Submitted: 2005-09-15 16:58 UTC Modified: 2005-09-27 19:05 UTC
From: madison at westga dot edu Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.4.0 OS: Solaris 9
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: madison at westga dot edu
New email:
PHP Version: OS:


 [2005-09-15 16:58 UTC] madison at westga dot edu
This bug: appears never to have been completely resolved.

Using the test code from the above bug...

If the code resides somewhere in the DocumentRoot then it works as expected. But, if it resides in a users public_html directory or inside an aliased directory, it doesn't give the correct path.

I get the same issue with the current CVS version of PHP5 and apache 2.

Reproduce code:
echo "original file is: " . __FILE__ . "<br>";

contents of test2.php:
echo "included file is: " . __FILE__ . "<br>";

$boo = "another try:  " . __FILE__;
echo $boo;

Expected result:
original file is: /home/madison/public_html/test.php
included file is: /home/madison/public_html/test2.php
another try: /home/madison/public_html/test2.php

Actual result:
original file is: /home/madison/public_html/test.php
included file is: ./test2.php
another try: ./test2.php


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-27 19:05 UTC]
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #34552 which is exactly same issue.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue May 26 18:01:28 2020 UTC