php - Syntax error when trying to put together constant and string -
this question has answer here:
- php parse/syntax errors; , how solve them? 12 answers
normally wouldn't post syntax errors here, case bit suspicious me. trying put constant string. works fine on localhost, when push project on web server, tells me:
parse error: syntax error, unexpected '.', expecting ',' or ';' in xxx on line xxx
code:
define("root", str_replace("index.php", "", $_server["script_filename"]));
and
$somepath = root . "some/path"; //synax error in line
has different php versions? (5.5 on webserver, 7.0 localhost)
update
some updates in code:
class someclass { private $somepath = root . "some/path"; //synax error in line ... }
you can't use str_replace()
nor function when defining contant. try:
define("root", $_server["script_filename"]); $somepath = str_replace("index.php", "", root) . "some/path";
please refer php manual:
in php 5, value must scalar value (integer, float, string, boolean, or null). in php 7, array values accepted.
Comments
Post a Comment