Welcome Guest, Not a member yet? Register   Sign In
Require, require_once, include and include_once not working correctly within hooks.
#1

[eluser]iancant[/eluser]
I seem to be having an issue including or requiring a file from within a hook file.
Code:
if(file_exists('C:/wamp/www/park_factor_network/system/application/shared/config/language.php'))
        {
            echo "yes";
            if(is_readable('C:/wamp/www/park_factor_network/system/application/shared/config/language.php'))
            {
                echo "is readable";
            }
            else
            {
                echo "is not readable";
            }

            require_once('C:/wamp/www/park_factor_network/system/application/shared/config/language.php') or die("Cannot Include Language Config");

            require_once('C:/wamp/www/park_factor_network/system/application/shared/config/some_file_that_is_not_there.php') or die("Cannot Include Language Config");

            require_once('system/application/shared/config/language.php') or die("Cannot Include Language Config");

            $fp = fopen('C:/wamp/www/park_factor_network/system/application/shared/config/language.php','r');
            fpassthru($fp);

            die();

        }
        else
        {
            echo "no";
        }

With this I get the following:
Code:
yes // result of file_exists()
is readable // result of is_readable()
A PHP Error was encountered

Severity: Warning

Message: require_once(1) [function.require-once]: failed to open stream: No such file or directory

Filename: hooks/select_language.php

Line Number: 25


Fatal error: require_once() [function.require]: Failed opening required '1' (include_path='.;C:\php5\pear') in C:\wamp\www\park_factor_network\system\application\shared\hooks\select_language.php on line 25

/* ########### // result of require_once() where file does exist ########### */

A PHP Error was encountered

Severity: Warning

Message: require_once(1) [function.require-once]: failed to open stream: No such file or directory

Filename: hooks/select_language.php

Line Number: 27


Fatal error: require_once() [function.require]: Failed opening required '1' (include_path='.;C:\php5\pear') in C:\wamp\www\park_factor_network\system\application\shared\hooks\select_language.php on line 27

/* ########### // result of require_once() where file does not exist ########### */

A PHP Error was encountered

Severity: Warning

Message: require_once(1) [function.require-once]: failed to open stream: No such file or directory

Filename: hooks/select_language.php

Line Number: 25


Fatal error: require_once() [function.require]: Failed opening required '1' (include_path='.;C:\php5\pear') in C:\wamp\www\park_factor_network\system\application\shared\hooks\select_language.php on line 25

/* ########### // result of require_once() with relative path ########### */

array('name' => 'English', 'folder' => 'english'), 'de'=> array('name' => 'German', 'folder' => 'german') ); /* |-------------------------------------------------------------------------- | Default Language |-------------------------------------------------------------------------- | | If no language is specified, which one to use? Must be in the array above | | en | */ $config['default_language'] = 'en'; /* End of file config.php */ /* Location: ./system/application/config/config.php */

/* ########### // result of fpassthru ########### */
(note I have rerun and commented out each require_once to show all parts of the code).

Operating System: Windows Vista
Web Server Package: WAMP - Apache 2.2.11 - PHP 5.3.1
Code Igniter: Version 1.7.2

If I create a require outside of code igniter's environment and try to include a file it:
a) works if the file exists
b) Warning: require_once(File_Does_Not_Exist.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\park_factor_network\shiter.php on line 3

Fatal error: require_once() [function.require]: Failed opening required 'File_Does_Not_Exist.php' (include_path='.;C:\php5\pear') in C:\wamp\www\park_factor_network\shiter.php on line 3


Messages In This Thread
Require, require_once, include and include_once not working correctly within hooks. - by El Forum - 07-04-2010, 06:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB