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'