Strange error when trying to run the latest version of php - php

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

Related

Laravel error after changing php version

I just setup php 7.0.27 in both webserver and cli. My laravel project was working just fine before in php 7.2. When I try run command php artisan serve it shows an error:
PHP Parse error: syntax error, unexpected '?', expecting variable
(T_VARIABLE) in /var/www/html/pmanager/pmanager/vendor/symfony/console
/Output/Output.php on line 40
I followed this github discussion which says that the solution is installing same versions in cli and webserver, which, in my case is fine. I have 7.0.27 in both.
Another thing they are pointing it out is laravel shows this error with php 7.0. I cannot change my php version to 7.1 or 7.2 because I must stick with it so as to run magento 2.1 projects.
Any help without changing php version would be highly appreciated.
you can downgrade your laravel 5.6 project to 5.5!!
Changing the value of the Laravel version inside the composer.json file to the laravel 5.5.
Delete /vendor folder and run composer install

PHP Parse error: syntax error, unexpected '?' - laravel

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.

Symfony Command Line Parse Error

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

Error when trying to install IPBoard (Invision Power Board) [duplicate]

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();");
}

PHP error after laravel installation

I would like to use laravel for my php project. I use WampServer2.2 (php 5.3.8 and Apache 2.2.21) on Windows 8.1. But after all kind of installation I tried (via composer or downloading the zip), when I get to the public folder in my browser I get PHP errors as :
Parse error: syntax error, unexpected '[' in C:\wamp\www\spi\laravel-master\vendor\laravel\framework\src\Illuminate\Support\helpers.php on line 411
or
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\wamp\www\spi\laravel-master\bootstrap\compiled.php on line 506
What may be the problem?
You say that your php version is 5.3.8 and the laravel docs say that 5.4 is required. The latest version(2.5) of WampServer comes with php 5.5.
upgrade PHP to PHP 5.6
You can use this command for local development server
php artisan serve

Categories