I am writing a php cli script, and my includes and requires are generating errors.
"PHP Warning: include_once(SCRIPT FOLDER): failed to open stream: Inappropriate ioctl for device in SCIPT PATH on line XX"
Im setting the working directory to the location of the script using
chdir(dirname(__FILE__));
and wrote a wrapper function to include files as such (just code fragments):
$this->_path = rtrim(realpath('./'), '/').'/';
public function require_file($file)
{
if (include_once $this->_path.$file === FALSE)
$this->fatal_error('Missing config file (config.php)');
}
What am I doing wrong, or missing?
Answer: (can't answer my own question less than 100 rep)
The proper thing to do when comparing return values from include is
if ((include 'file') === FALSE)
doing it in the wrong fashion will evaluate to include '', causing my error.
$this->_path.$file? did you log that to check it ?$file? does the file exists ? is it readable ? ... ?