|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-04-04 07:07 UTC] seufert at gmail dot com
Description:
------------
Also tested on PHP 5.5.5 on Windows 7 x64
Issue seems to be todo with order of operations, the filename is being ignored, and perhaps FALSE is being used.
If you change the script to FALSE === require_once(...) it works perfectly.
Test script:
---------------
<?php
if(require_once("myclass.php") === FALSE) {
echo "Hi there was a problem";
}
new myclass();
Expected result:
----------------
No errors
Actual result:
--------------
Inappropriate ioctl for device in /.../test.php on line 2
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 06 21:00:01 2026 UTC |
That is no bug, include_once/require_once is a language construct not a function, so include_once("myclass.php") === FALSE can (should) be written as include_once "myclass.php" === FALSE which binds like include_once ("myclass.php" === FALSE) which evaluates to include_once FALSE which converts to include_once "" which fails. Both manual pages for "include_once" (used in your bug summary) and "require_once" (used in your description and script) ultimately link to the "include" documentation [ http://www.php.net/manual/en/function.include.php ] which warns about that: """ Because include is a special language construct, parentheses are not needed around its argument. Take care when comparing return value. Example #4 Comparing return value of include <?php // won't work, evaluated as include(('vars.php') == 'OK'), i.e. include('') if (include('vars.php') == 'OK') { echo 'OK'; } // works if ((include 'vars.php') == 'OK') { echo 'OK'; } ?> """ Incidentally, testing ((require_once "myclass.php") === FALSE) or (FALSE === require_once "myclass.php") in your script is useless since, as opposed to include/include_once, a failing require/require_once will produce a fatal error and stop the execution.