0
Work on a Wordpress site using: PHP 7.0 and Microsoft-IIS/10.0.
The site is up and running, but occasionally errors appear in the log, usually errors related to Constants __DIR__
and __FILE__
coupled with 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 recorded are similar to these:
It shows only half the way that the __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'
Are you willing to list the contents of the file ? Can you tell me better what you are trying to accomplish ?
– Matheus Martins
I just do the file require. And the way it is now works perfectly, I did several tests debugging the whole process. However in production occasionally this error is recorded and when it occurs the site gets off the air.
– Kaue Alves
Which version of PHP? This seems to me a configuration bug, using IIS?
– Guilherme Nascimento
I’m using IIS and it’s PHP 7.0
– Kaue Alves