Click here to Skip to main content
15,887,323 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My website was showing error currently unable to handle this request HTTP ERROR 500 when i enabled the error display the main error is.
PHP
Parse error: syntax error, unexpected ')', expecting :: (T_PAAMAYIM_NEKUDOTAYIM) in /home/afghauri/public_html/config.php on line 211


here is what line 211 looks in my code.
PHP
if ( empty(BASE_PATH) || $base == 'BASE_PATH' ) {

BASE_PATH is a Magic Constant defined on line 48 as
PHP
define('BASE_PATH', __DIR__);

here is line 210 and 212 of my code.
210
PHP
$base = BASE_PATH;

212
PHP
$base = __DIR__;

Update
the strangest thing is that it's working perfectly in localhost but when i upload it to my cpanel it starts doing that

What I have tried:

i tried changing the
PHP
if(empty(BASE_PATH)
into
PHP
if(BASE_PATH === NULL
that worked but it messed up my websites interface.
Posted
Updated 6-Aug-18 18:04pm
v2

1 solution

PHP: empty - Manual[^] determines if a variable is considered to be empty but BASE_PATH is a named constant.

To check if a named constant is defined use PHP: defined - Manual[^].

But a named constant might be defined and empty. So you would have to assign the constant to a variable:
PHP
if (defined('BASE_PATH')) {
    $base = BASE_PATH;
    // or: $base = constant(BASE_PATH);
    if (empty($temp)) {
        $base = __DIR__;
    }
}

Overall it would be probably better to use a variable initially instead of a named constant.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900