简体   繁体   中英

Error :Function must be terminated with a string in CodeIgniter's constants.php

While writing this line :-

define('APPLICATION_ROOT', $_SERVER('DOCUMENT_ROOT') );

in constants.php in CodeIgniter framework of PHP i get error Error :Function must be terminated with a string . Can i not use Super Global arrays in constants.php?

define('APPLICATION_ROOT', $_SERVER['DOCUMENT_ROOT'] );

Brackets [ ], not parentheses.

Though I will recommend against doing that. Constants are supposed to be, well, constant. $_SERVER['DOCUMENT_ROOT'] might not be defined or the same everywhere you use it.

I don't have an instance of CI up at the moment, but shouldn't that line be:

define('APPLICATION_ROOT', $_SERVER['DOCUMENT_ROOT']);

(With the square braces instead of parens)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM