ERRORS with INCLUDE_ONCE Global Variable PHP -
i created config file has variable want use constant.
<?php $root_path = 'c:/users/me/documents/app-qas.com/site'; ?> on class page want use variable added following before instantiating class:
include_once("config.php"); $root=$root_path; i made appropriate scoping changes functions in class follows: global $root; include_once($root."/library/api/database.inc.php");
when run app, does perform of data connections designed do, still returns following errors:
warning: include_once(config.php): failed open stream: no such file or directory in c:/users/me/documents/app-qas.com/site'\class\posting.class.php on line 5
warning: include_once(): failed opening 'config.php' inclusion (include_path='.;c:\php\pear') in c:/users/me/documents/app-qas.com/site'\class\posting.class.php on line 5
notice: undefined variable: root_path in c:/users/me/documents/app-qas.com/site'\class\posting.class.php on line 6
warning: include_once(/library/api/database.inc.php): failed open stream: no such file or directory in c:/users/me/documents/app-qas.com/site'\class\posting.class.php on line 112
warning: include_once(): failed opening '/library/api/database.inc.php' inclusion (include_path='.;c:\php\pear') in c:/users/me/documents/app-qas.com/site'\class\posting.class.php on line 112
warning: include_once(/library/api/database.inc.php): failed open stream: no such file or directory in c:/users/me/documents/app-qas.com/site'\class\posting.class.php on line 112
warning: include_once(): failed opening '/library/api/database.inc.php' inclusion (include_path='.;c:\php\pear') in c:/users/me/documents/app-qas.com/site'\class\posting.class.php on line 112
if comment out include , hard code $root runs before does not throw errors:
#include_once("joblaunch.php"); #$root=$root_path; $root='c:/users/me/documents/app-qas.com/site'; i don't understand why runs , throws errors when getting variable config.php runs , doesn't throw error when hard coding path.
if define constant instead of variable, problem should solved,
definition
old:
$root_path = 'c:/users/me/documents/app-qas.com/site'; new:
define('root_path', 'c:/users/me/documents/app-qas.com/site'); usage
old:
$root=$root_path; new:
$root = root_path;
Comments
Post a Comment