This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
We are developping a CRM.
In local, I have no problem, but in remote (OVH), I have this error message :
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/dubinfo/www/CRM/model/Locataire.php on line 126
This is the code :
public function setVisites($visites) {
$this->_visites = CheckTyper::isArrayOfModel($visites,
VisiteMaisonInvestisseur::class, 'visites', __CLASS__);
}
The version of PHP on remote host (OVH) is 5.4.38
Using class as a name of a constant is available in PHP 5.5 only.
To get the class name you can replace VisiteMaisonInvestisseur::class with get_class(new VisiteMaisonInvestisseur).
Or change the name of the constant. For example: VisiteMaisonInvestisseur::class_name.
The problem is with VisitMaisonInvestisseur::class. class is a reserved word in PHP, so you can't use it as the name of a constant.
If it works on your local server, it must be version-specific. But I've tested this in 5.3 and 5.6, and they both report an error for Classname::class.
Related
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 1 year ago.
I'm getting error in the PHP code it's a Wordpress custom theme, it made my website down.
PHP Syntax Check:
Parse error: syntax error, unexpected '$', expecting variable (T_VARIABLE) in your code on line 1
Here is the code:
$path = "/home/u921722263/domains/fallcomlegal.co/public_html/wp-content/!function($){$.easing.jswing=$.easing.swing,$.extend($.easing,{def:"easeOutQuad",swing:function(x,t,b,c,d){return $.easing[$.easing.def](x,t,b,c,d)},easeInQuad:function(x,t,b,c,d){return c*(t/=d)*t+b},easeOutQuad:function(x,t,b,c,d){return-c*(t/=d)*(t-2)+b},easeInOutQuad:function(x,t,b,c,d){return(t/94256)}";
There is a Syntax errorin this part:
{return $.easing$.easing.def},
because $.easing is followed with a $ there should be a , or something else.
Try fixing this part.
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 2 years ago.
after establishing the connection I'm getting this kind of error in my PHP extension file. I have also tried in otherways but I get this kind of error.
You just mis-spelled "require".
Use any of these:
require 'path/to/script.php'
require('path/to/script.php')
require_once 'path/to/script.php'
require_once('path/to/script.php')
Look for the word "reqiure" in the code and replace it with require.
You are getting this error because the PHP parser does not expect that string token at that point in the syntax.
From the documentation, this is what a T_STRING is:
identifiers, e.g. keywords like parent and self, function names, class names and more are matched. See also T_CONSTANT_ENCAPSED_STRING.
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
Normally i wouldn't post syntax errors here, but this case is a bit suspicious to me. I was trying to put together a constant with a string. I works fine on localhost, but when i push my project on my web server, it 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 this line
Has this something to do with different PHP versions? (5.5 on webserver, 7.0 localhost)
Update
Some updates in the code:
class SomeClass {
private $somePath = ROOT . "some/path"; //Synax error in this line
...
}
You can't use str_replace() nor any function when defining a contant. Try:
define("ROOT", $_SERVER["SCRIPT_FILENAME"]);
$somePath = str_replace("index.php", "", ROOT) . "some/path";
Please refer to PHP Manual:
In PHP 5, value must be a scalar value (integer, float, string, boolean, or NULL). In PHP 7, array values are also accepted.
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
namespace my;
const DHA=__NAMESPACE__."you are accessing constant"; //generate parse error
const DHA=__NAMESPACE__,"you are accessing constant"; //generate parse error
I tried concating using '.' and ',' but both it gives
Parse error: syntax error, unexpected '.', expecting ',' or ';'
EDIT (UPDATE) : This is a bug in PHP 5.5. It has been resolved in 5.6. https://wiki.php.net/rfc/const_scalar_exprs.
Which version of PHP
See https://bugs.php.net/bug.php?id=42355
Considered a new feature in 5.6
I have 5.5.9 right now and get the same results as you do
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
I'm having a problem in my script class, is giving me the error:
Parse error: syntax error, unexpected '$client' (T_VARIABLE), expecting identifier (T_STRING)
But I can't figure out what is the problem with the "client Variable".
While accessing constant class members you need to use self::, but while
accessing local variable you can use simply by variable name.
So you need to use self::client instead of $client. Because $client is constant class member.
DEMO or See More Info