Questions tagged [php-7.1]

The successor to PHP 7.0. Use this tag for version-specific issues relating specifically to PHP 7.1.

517 questions
271
votes
19 answers

Switch php versions on commandline ubuntu 16.04

I have installed php 5.6 and and php 7.1 on my Ubuntu 16.04 I know with Apache as my web server, I can do a2enmod php5.6 #to enable php5 a2enmod php7.1 #to enable php7 When I disable php7.1 in Apache modules and enable php 5.6, Apache recognizes…
salimsaid
  • 3,186
  • 4
  • 15
  • 20
140
votes
13 answers

PHP7.1 json_encode() Float Issue

This isn't a question as it is more of a be aware. I updated an application that uses json_encode() to PHP7.1.1 and I was seeing an issue with floats being changed to sometimes extend out 17 digits. According to documentation, PHP 7.1.x started to…
Gwi7d31
  • 1,652
  • 2
  • 12
  • 10
73
votes
8 answers

Silence "Declaration ... should be compatible" warnings in PHP 7

After upgrade to PHP 7 the logs almost choked on this kind of errors: PHP Warning: Declaration of Example::do($a, $b, $c) should be compatible with ParentOfExample::do($c = null) in Example.php on line 22548 How do I silence these and only these…
sanmai
  • 29,083
  • 12
  • 64
  • 76
27
votes
8 answers

PHP iterable to array or Traversable

I'm quite happy that PHP 7.1 introduced the iterable pseudo-type. Now while this is great when just looping over a parameter of this type, it is unclear to me what to do when you need to pass it to PHP functions that accept just an array or just a…
Jeroen De Dauw
  • 10,321
  • 15
  • 56
  • 79
27
votes
4 answers

How to install bcmath in Ubuntu for PHP 7.1

I'm using an Ubuntu 16 server for testing with php7.1. One of my app uses bcadd function. I know that I need to install bcmath module for that but I'm unable to find php7.1-bcmath. When I tried to install apt install php-bcmath, it simply installed…
Vajira Lasantha
  • 2,435
  • 3
  • 23
  • 39
20
votes
2 answers

Returning NULL with return type declarations

I was refactoring a codebase for use with PHP7, particularly implementing scalar type hints and return type hints, when I encountered an problem. I have a class with some properties, one of which an id. This id is not mandatory (you can construct an…
Compizfox
  • 748
  • 2
  • 7
  • 17
20
votes
4 answers

PHP Traversable type hint

I have a relatively simple function which uses a foreach function foo($t) { $result; foreach($t as $val) { $result = dosomething($result, $val); } return $result; } I would like to type hint, and Traversable seems to be…
dtech
  • 13,741
  • 11
  • 48
  • 73
19
votes
6 answers

Homebrew PHP appears not to be linked. - Valet

I had a problem which appeared all of the sudden saying: Unable to determine linked PHP. which I could not solve so I uninstalled valet, php and dependencies. Then I installed fresh php7.1 but when I run valet install I get quiet slightly similar…
Epsilon47
  • 768
  • 1
  • 13
  • 28
19
votes
1 answer

How to use default value when `null` is given for a nullable function parameter?

In PHP 7.1 when the following function is called: private function doStuff(?int $limit = 999) { } with syntax like so: doStuff(null); the value of $limit becomes null. So I guess it can be said that the value of $limit was explicitly set to…
mils
  • 1,878
  • 2
  • 21
  • 42
16
votes
5 answers

PHP7.1 mcrypt alternative

Mcrypt function has been deprecated as of PHP 7.1.0. My deprecated string encode / decode functions: $key: secret key $str: string $encoded = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $str, MCRYPT_MODE_CBC,…
Tibi
  • 163
  • 1
  • 1
  • 6
15
votes
4 answers

Change mac os x default php version

In my mac (version 10.13.6 High Sierra) php -v output is PHP 7.1.32 . I need to update this 7.1 version to 7.3. i tried to remove this version using brew unlink php7.1 but it's not worked. How can i upgrade php version.
C.V
  • 909
  • 2
  • 9
  • 20
14
votes
2 answers

PHP can not load Imagick library - PHP Startup: Unable to load dynamic library

I have High Sierra OS - Version 10.13.6 PHP Version: PHP 7.1.9 when I try to do command php -v always appear error like this: PHP Startup: Unable to load dynamic library …
Vive
  • 198
  • 1
  • 1
  • 12
13
votes
1 answer

What is hard_timeout in PHP Core config?

Available since PHP 7.1.0, hard_timeout have 2 seconds as default value and accept integgers as value. At documentation, http://php.net/manual/en/ini.core.php#ini.hard-timeout, there is no additional information available. What's the difference…
LeonanCarvalho
  • 1,819
  • 3
  • 20
  • 39
13
votes
2 answers

How to install PHP Opcache on MacOS High Sierra?

I'm using the standard Apache and PHP 7.1 (not Homebrew) that comes with Mac High Sierra. However, it appears that this version doesn't have Opcache enabled even though it should come as standard with PHP 7. It's even listed in phpinfo() under…
DisgruntledGoat
  • 70,219
  • 68
  • 205
  • 290
12
votes
3 answers

Can't catch exceptions in laravel

I have the following situation: try { DB::beginTransaction(); $task = new Task(); $task->setTracker(""); //thrown \Symfony\Component\Debug\Exception\FatalThrowableError DB::commit(); }catch…
SexyMF
  • 10,657
  • 33
  • 102
  • 206
1
2 3
34 35