Magical Constants Returning Null or Half Way

0

Work on a Wordpress site using: PHP 7.0 and Microsoft-IIS / 10.0.

The site is up and running, but occasionally some errors appear in the log, usually errors are related to the constants __DIR__ and __FILE__ linked to require functions.

require (__DIR__.'/file.php');

require_once (__DIR__.'/file.php');

require ( dirname(__FILE__).'/file.php');

require_once ( dirname(__FILE__).'/file.php');

require (__DIR__ . DIRECTORY_SEPARATOR . 'arquivo.php');

The errors that are logged are similar to these:

Show only half of the path that __FILE__ should receive:

// Função: require_once dirname( __FILE__ ) . '/file.php';

Erro: PHP Fatal error:  require_once(): Failed opening required 'D:\home\site\wwwroot\wp-content\themes/file.php' (include_path='.;C:\php\pear\') in D:\home\site\wwwroot\wp-content\themes\l on line 22

__DIR__ does not return any path:

//Função: require_once __DIR__ . '/file.php';
Erro: PHP Fatal error:  require_once(): Failed opening required '/file.php'
    
asked by anonymous 20.02.2018 / 14:12

1 answer

1

Give a var_dump in __DIR__ . DIRECTORY_SEPARATOR . 'arquivo.php' and see what it returns.

If you copy the link that returned and that link, in the URL bar you return some file, the problem is another.

EDIT

Try instead of __DIR__ o dirname( __FILE__ )

    
20.02.2018 / 14:56