Skip to content
Advertisement

Why do I get this error define() expects at least 2 parameters, 1 given [closed]

I have been following a course,

Here are all the errors I get:


Warning: defined() expects exactly 1 parameter, 2 given in C:xampphtdocsSitesphoto_galleryincludesinitialize.php on line 5

Notice: Use of undefined constant SITE_ROOT – assumed ‘SITE_ROOT’ in C:xampphtdocsSitesphoto_galleryincludesinitialize.php on line 7

Warning: require_once(SITE_ROOTincludesconfig.php): failed to open stream: No such file or directory in C:xampphtdocsSitesphoto_galleryincludesinitialize.php on line 9

Fatal error: require_once(): Failed opening required ‘SITE_ROOTincludesconfig.php’ (include_path=’.;C:xamppphpPEAR’) in C:xampphtdocsSitesphoto_galleryincludesinitialize.php on line 9

My Code:

define('DS') ? null : define('DS', DIRECTORY_SEPARATOR);

define('SITE_ROOT') ? null :
define('SITE_ROOT', DS.'sample'.DS.'samples'.DS.'samples'.DS.'samples');

define('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes');

require_once(LIB_PATH.DS.'config.php');
require_once(LIB_PATH.DS.'function.php');
require_once(LIB_PATH.DS.'session.php');
require_once(LIB_PATH.DS.'database.php');
require_once(LIB_PATH.DS.'user.php');

Advertisement

Answer

Replace your defines with the below

defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);

defined('SITE_ROOT') ? null :
define('SITE_ROOT', DS.'sample'.DS.'samples'.DS.'samples'.DS.'samples');
defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes');
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement