php - Syntax error when trying to put together constant and string -


this question has answer here:

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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -