PHP `require_once` includes invalid file

I have a Linux Ubuntu 14.04-LTS development tree, like this, with three identical branches:

main -+-- leonardo --- project --- htdocs -+- panel --- index.php
      |                                    |
      |                                    +- config.php
      |
      +-- federico --- project --- htdocs -+- panel --- index.php
      |                                    |
      |                                    +- config.php
      |
      +-- carlo ------ project --- htdocs -+- panel --- index.php
      |                                    |
      |                                    +- config.php
    ..... (you get my drift).

There are neither soft links nor hard links . The file config.phpis in svn-ignore and is different from all branches

There is an Apache server, and for each developer there is virtualHost, so I see my development version http: //leonardo.project.local or Federico at http: //federico.project.local .

When examining the current oddity, these two files:

<?php // this is panel/index.php
    echo "I am " . __FILE__ . "\n";
    echo "I will include " . realpath('../config.php') . "\n";
    require_once '../config.php';

<?php // this is config.php
    echo "I am " . __FILE__ . "\n";
    exit();

The expected result, of course, will be as follows:

I am leonardo/project/htdocs/panel/index.php
I will include /var/www/main/leonardo/project/htdocs/config.php
I am leonardo/project/htdocs/config.php

But the actual conclusion:

I am leonardo/project/htdocs/panel/index.php
I will include /var/www/main/leonardo/project/htdocs/config.php
I am federico/project/htdocs/config.php

An additional oddity is that

    echo "I will include " . realpath('../config.php') . "\n";
    require_once realpath('../config.php');

work.

TL DR require_once and realpathdisagree with where "../config.php" actually is.

- , , script leonardo/project/htdocs/panel/ federico/project/htdocs/config.php; , .

, - .

ext4, ​​- 3.13.0-55-generic #92-Ubuntu SMP Sun Jun 14 18:32:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux. x64 VMware.

  • PHP include_path . /usr/local/php5/pear.
  • , , . .
  • , " ".
  • , leonardo... "cat../config.php", config.php, . PHP .
  • Apache ( ) . , , .
  • hunky ( ). , . .
  • : , , . , .
+4
2

- ? , , .

, , opcache.use_cwd .

opcache.use_cwd boolean

, OPcache ​​ script, . , , .

, phpunit script, (, leonardo/config.php vs federico/config.php), "" . , realpath, . , , . .

, , , . , .

, , . , , - use_cwd, , "../inc/credit_cards.php", . get_defined_vars() , . ( , , , , ).

+1

, include_path ( get_include_path).

require include - .

require_once realpath('../config.php');

:

require_once '/var/www/main/leonardo/project/htdocs/config.php';

, .

:

require_once '../config.php';

, PHP include . , , federico.

+3

All Articles