Parse error: syntax error, unexpected ‘|’, expecting variable (T_VARIABLE) Symfony PHP VERSION WAMP Windows
With several search, I saw the problem is from PHP version (have to be > 7.1), but actually my version is 7.4.9, this is a local machine, i’m working with WAMP on Windows. Symfony 4.4 version. Already tried to delete vendor, .lock. Here the php version from phpinfo() Here php version from wamp
Here php version from CLI php-v
Here my composer.json
< "type": "project", "license": "proprietary", "require": < "php": ">=7.1.3", "ext-ctype": "*", "ext-iconv": "*", "doctrine/annotations": "^1.13", "mongodb/mongodb": "^1.10@dev", "ramsey/uuid": "^4.2", "symfony/console": "4.4.*", "symfony/dotenv": "4.4.*", "symfony/flex": "^1.3.1", "symfony/form": "4.4.*", "symfony/framework-bundle": "4.4.*", "symfony/messenger": "4.4.*", "symfony/yaml": "4.4.*" >, "require-dev": < >, "minimum-stability": "dev", "config": < "preferred-install": < "*": "dist" >, "sort-packages": true, "platform": < "php": "7.4.9" >>, "autoload": < "psr-4": < "App\\": "src/" >>, "autoload-dev": < "psr-4": < "App\\Tests\\": "tests/" >>, "replace": < "paragonie/random_compat": "2.*", "symfony/polyfill-ctype": "*", "symfony/polyfill-iconv": "*", "symfony/polyfill-php71": "*", "symfony/polyfill-php70": "*", "symfony/polyfill-php56": "*" >, "scripts": < "auto-scripts": < "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" >, "post-install-cmd": [ "@auto-scripts" ], "post-update-cmd": [ "@auto-scripts" ] >, "conflict": < "symfony/symfony": "*" >, "extra": < "symfony": < "allow-contrib": false, "require": "4.4.*" >> >
Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project
I have got the following error in my Laravel project after uploading in Bluehost cPanel. But in local server there is no error.
My local server PHP version is 7.2.0 Bluehost PHP version is 7.0.0 Is that PHP version related problem? How to fix this?
I vote to reopen this question, because the alleged duplicate question doesn’t address this error message. A simple search for ‘T_CONST’ reveals this.
2 Answers 2
The ability to specify the visibility of class constants was only added in PHP 7.1, from the manual page
Note:
As of PHP 7.1.0 visibility modifiers are allowed for class constants.
So on the PHP 7.0 server, the
public const TRANSACTION_READ_UNCOMMITTED .
lines should not have the public on them. It also says that
The default visibility of class constants is public.
So public is not needed anyway.
got this error from an installed composer package we didn’t want to downgrade, so we upgraded php: e.g: php.watch/articles/Ubuntu-PHP-7.4, kenfavors.com/code/…
It seems like you want to define a constant variable.
syntax error, unexpected ‘const’ (T_CONST) in .
I changed that instruction to :
define('CONSTANT', 'jkl'); echo CONSTANT;
Syntax of the method ‘define’ :
define('variable_name', 'value_of_the_variable', [case-insensitive_constant_name = true/false]);
define('CONSTANT3', 'ghi', true); echo CONSTANT3; define('constant3', 'ghi'); //Defining 'constant3' again will give an error.
define('CONSTANT3', 'ghi'); echo CONSTANT3; define('constant3', 'ghi'); //This won't give an error. echo constant3;
Always remember that regular variables should be addressed by using ‘$’ before their name but constant variables should be addressed directly as shown by me in the code above.
unexpected ‘(‘, expecting ‘&’ or variable (T_VARIABLE) [closed]
What is isAdmin() ? The function definition is expecting a variable there, not another function. Check the PHP documentation for function arguments for more info. php.net/manual/en/functions.arguments.php
3 Answers 3
The function is expecting a variable, you have given an expression, thats why it is an error
function ongoing_cases_control(isAdmin())
Here isAdmin() is a function, you have to put a variable there.
You need to define a variable, then you can pass the result of a function
function ongoing_cases_control($isAdmin) < if ($isAdmin) < // Note "== 1" will be true for any value that evaluates to true, so might as well just check for any value that evaluates to true. // Return the result so you don't have side effects return ' Ongoing Cases Panel You can edit, add on ongoing cases
'; > >
echo ongoing_cases_control(isAdmin());
you have 2 problems assuming this is the whole snippet. you cannot put an expression in a function declaration, and you have missed a closing > .
function ongoing_cases_control($isAdmin) < //Ongoing Cases PanelYou can edit, add on ongoing cases