php.net |  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
 [2005-09-15 16:58 UTC] madison at westga dot edu
Description:
------------
This bug: http://bugs.php.net/bug.php?id=13936 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:
---------------
<?php
echo "original file is: " . __FILE__ . "<br>";
include("test2.php");
?>

contents of test2.php:
<?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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-27 19:05 UTC] sniper@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 00:01:27 2024 UTC