Recent Posts

How to solve: Warning: [function]: failed to open stream in PHP

It happens when you call a file usually by includerequire or fopen and PHP couldn't find the file or have not enough permission to load the file.

One common mistake is to not use an absolute path. This can be easily solved by using a full path ormagic constants like __DIR__ or dirname(__FILE__)

include __DIR__ . '/inc/globals.inc.php';
or:
require dirname(__FILE__) . '/inc/globals.inc.php';
Ensuring the right path is used is one step in troubleshooting these issues, this can also be related to non-existing files, rights of the filesystem preventing access or open basedir restrictions by PHP itself.

No comments:

Post a Comment