I'm using laravel 5.5 framework.It requirements PHP >= 7.0.0.
when I run server I got this error (php artisan serve):
PHP Parse error: syntax error, unexpected '?' in E:\xampp\htdocs\dibit\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php on line 233
I've installed the last version of xampp and phpstorm.
I think this error show I'm not using php 7.
in my console of my phpstorm when I run this commend:
php -v
it returns PHP 5.6.21.
where is my problem?
the result of this code:
<?php
echo phpversion();
?>
is:
7.2.1
http://localhost/p.php
I have two xampp software but them have been installed an
It looks to me like your command prompt uses an old php version. To confirm that, run
where php
in a command prompt and find out whether it prints the right path (to PHP7). If it's incorrect, check the PATH environment variable and modify it with the correct path to PHP7.
Hope it helps.
Good afternoon,
I'm working on a symfony project and everything was going well until I received the following messages :
PHP Warning: Unsupported declare 'strict_types' in .../vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php on line 19
PHP Parse error: parse error, expecting ';'' or '{'' in .../vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php on line 97
These 2 messages appear whenever I try to use the command line in symfony.
I tried the following commands:
php app/console generate:doctrine:entity
and
php app/console cache:clear --env=prod.
I also tried to use php bin/console instead of app/console as I'm aware the new symfony versions use php bin/console.
I'm using Mamp with php version 7.1 and Symfony version 2.8 for the projects.
Thanks for your help!
If someone runs into this issue it means that your php version is not 7.0 The issue I had was that the Mamp version was 7.1.1 and the symfony project was also running on 7.1.1 in the browser but when I checked the php version in the bash commands, it was 5.6 so make sure you're bash commands use php 7.0 instead of 5.6
My client says he is getting this error using my script:
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /path/to//header.php on line 34
Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in/path/to/header.php on line 34
The line 34 in header.php is just use \Main\Class;
Now, I told him he has to have PHP >= 5.3.0 and he says his PHP version is 5.3.24
What could be the problem?
EDIT: The lines before and after
30. // Define absolute path
31. define("ABSPATH", $abs_path);
32. $_SESSION["abs_path"] = ABSPATH;
33.
34. use \CNS\main\CNS;
35. $cns = new CNS();
EDIT 2:
He sent me this:
Program Version
Apache: 2.2.24
CentOS: CentOS release 6.4 (Final)
cPanel: 11.36.1 (build 8)
Curl: 7.12.1
MySQL 5.5.30
phpMyAdmin 3.5.5
Python: 2.6.6
Program Version
Perl: 5.8.8
**PHP: 5.3.24**
ionCube Loader: 4.2.2
Zend Optimizer: 3.3.9
Ruby: 1.8.7
Rails: 3.2.8
OpenSSL: 1.0.0-fips
This happens if you are trying to use namespaces but do not have PHP 5.3. PHP 5.2 and below don't support namespaces and throw this error when they see the backslash.
--
Edit: mixed up the versions. It's 5.2 and below that don't have namespaces, if I'm not mistaken.
Now, I told him he has to have PHP >= 5.3.0 and he says his PHP version is 5.3.24
What could be the problem?
His PHP version is actually < 5.3.0, whether he knows that or not.
See the error occurring on many PHP versions.
If you get 'unexpected T_STRING' error after your mentioned error, you need to install PHP 5.4+
Ask him to create a file with phpinfo(). He probably doesn't have PHP version >= 5.3.0.
<FilesMatch "\.(inc|php|php3|php4|php44|php5|php52|php53|php54|php55|php56|phtml|phps)$">
AddHandler x-httpd-php53 .php
</FilesMatch>
in .htaccess
I ran the same problem, and doing some research I managed to fix it.
In my case, I use PHP7, and what I had to do is edit the file laravel located in ~/.composer/vendor/laravel/installer/, where the shebang line was #!/usr/bin/env php I changed to #!/usr/bin/env php7
After run again the artisan, I got it working:
-bash-3.2$ laravel
Laravel Installer version 1.3.3
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
list Lists commands
new Create a new Laravel application.
Like other users say: use of namespaces are only valid for PHP versions greater than 5.3.0 so my solution for be able to include an optional use of a library using namespaces is to check the php version and use the eval() function to avoid that lower versions of PHP shoot an error, even on compilation time.
Something like this:
if ( phpversion() > '5.3.0' ){
include_once('/path/to/Library.php');
eval("Library\Foo::bar();");
}
I have been attempting to install symfony on my website however I have had little success as it depends on composer.
To install:
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
When I attempted the install (all install options appear to require phar support) I got this output:
-----------------------------------------------------------
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in Command line code(1) : eval()'d code on line 378
#!/usr/bin/env php
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The phar extension is missing.
Install it or recompile php without --disable-phar
Your PHP (5.2.8) is too old, you must upgrade to PHP 5.3.2 or higher.
-----------------------------------------------------------
I do not have privileges to install a different version of php as I am using a paid webhost that is somewhat restrictive. What are my options?
Symfony 2 doesn't support php < 5.3.2 http://symfony.com/doc/2.0/reference/requirements.html
If you cannot upgrade your php version then find another web host or use a different framework.
I followed this guide and then I added /usr/local/bin before the whole $PATH variable so that the newly installed version runs first (instead of the default one).
Then when I tried to run php -version from the command line, I get the following error :
Parse error: syntax error, unexpected end of file in Command line code on line 1
I am running Mountain Lion.
It seems that php -version is deprecated for php v5.4.x
I tried php -v and it works for both php 5.3.x and php 5.4.x