I have the following
code
define("SCRIPT_URL",
"");
function ifScriptFolder() {
if(isset(SCRIPT_URL) &&
!empty(SCRIPT_URL)) {
echo "/".SCRIPT_URL."/";
} else {
echo "/";
}
}
but
it's giving me the following
error:
Parse error: syntax error,
unexpected ')', expecting :: (T_PAAMAYIM_NEKUDOTAYIM) in *(path)* on line
3
Can anyone see
what's going wrong here or how to fix it?
If you trying to determine if
constant exists, then try to use rel="noreferrer">defined()
or href="http://php.net/constant"
rel="noreferrer">constant()
, not href="http://php.net/isset"
rel="noreferrer">isset()
.
/>
From rel="noreferrer">php.net:
Function
rel="noreferrer">defined()
:
Returns TRUE if the named constant given by name has been defined, FALSE
otherwise.
Function
rel="noreferrer">constant()
:
Returns the value of the constant, or NULL if the constant is not
defined.
/>
Fixed
function:
function
ifScriptFolder() {
echo defined('SCRIPT_URL') ? "/" . constant('SCRIPT_URL')
. "/" :
"/"
}
UPD:
The
defined()
function is a better solution for this, because it
will not emit E_WARNING
if constant was not
defined.
No comments:
Post a Comment