Questions tagged [php-7]

PHP 7 is the successor to PHP 5.6, it was released on December 3, 2015. Use this tag for issues relating to development using PHP 7

PHP 7 is the next version of . It succeeds , which is the last release of the PHP 5.X version. PHP 7.0.0 was released on Dec 3, 2015

PHP 6

Several years ago there was a major push to make PHP Unicode compatible and this push focused around what was then slated to be PHP 6. An internal version was developed and a lot of material was published (including some books) about this new version. Serious problems with the implementation arose, however, and the project was abandoned, with most of the surviving code being implemented in PHP 5.4. To avoid confusion with this discussion the decision was made to skip version 6.

Development

You can download the PHP 7 source and compile it yourself. Official builds are available on the PHP website.

Features

New features of PHP 7 include (See all accepted features):

PHP7 migration guide

There's a whole section on Migrating from PHP 5.6.x to PHP 7.0.x in the manual:

© 1997-2015, The PHP Documentation group, CC-BY 3.0

Information

  • For global question on PHP, please use the generic tag:
  • If you want to talk about PHP or if you have a question, you can come to the PHP chat room
2761 questions
324
votes
4 answers

PHP7 : install ext-dom issue

I'm running laravel 5.4 on Ubuntu 16.04 server with PHP7. trying to install cviebrock/eloquent-sluggable package throw some error: pish@let:/home/sherk/ftp/www$ sudo composer require cviebrock/eloquent-sluggable Do not run Composer as root/super…
alex
  • 7,551
  • 13
  • 48
  • 80
269
votes
3 answers

What is <=> (the 'Spaceship' Operator) in PHP 7?

PHP 7 introduced the Spaceship (<=>) operator. What is it and how does it work?
Deepak Mankotia
  • 4,404
  • 6
  • 30
  • 55
260
votes
12 answers

How do I install the ext-curl extension with PHP 7?

I've installed PHP 7 using this repo, but when I try to run composer install, it's giving this error: [package] requires ext-curl * -> the requested PHP extension curl is missing from your system. With PHP 5, you can easily install it by running…
Stephan Vierkant
  • 9,674
  • 8
  • 61
  • 97
201
votes
3 answers

Nullable return types in PHP7

PHP 7 introduces return type declarations. Which means I can now indicate the return value is a certain class, interface, array, callable or one of the newly hintable scalar types, as is possible for function parameters. function returnHello():…
Jeroen De Dauw
  • 10,321
  • 15
  • 56
  • 79
174
votes
9 answers

PHP 7: Missing VCRUNTIME140.dll

I have an error when I start PHP 7 on Windows. When I run php on the command line, it returns a message box with system error: The program can't start because VCRUNTIME140.dll is missing from your computer. Try reinstalling the program to fix this…
Félix Desjardins
  • 3,223
  • 3
  • 21
  • 36
147
votes
2 answers

Why I am suddenly getting a "Typed property must not be accessed before initialization" error when introducing properties type hints?

I have updated my class definitions to make use of the newly introduced property type hints, like this: class Foo { private int $id; private ?string $val; private DateTimeInterface $createdAt; private ?DateTimeInterface…
yivi
  • 42,438
  • 18
  • 116
  • 138
136
votes
3 answers

What is the difference between fastcgi and fpm?

I am trying to install php with fpm on macports. I read somewhere that fpm means FastCGI process manager. Does that mean fastcgi and fpm are same? If they are same, then why do we have two different macports variants for php namely "php5 +fastcgi"…
Deepan Chakravarthy
  • 4,154
  • 7
  • 25
  • 21
126
votes
10 answers

mcrypt is deprecated, what is the alternative?

The mcrypt-extension is deprecated will be removed in PHP 7.2 according to the comment posted here. So I am looking for an alternative way to encrypt passwords. Right now I am using something like mcrypt_encrypt(MCRYPT_RIJNDAEL_128, md5($key, true),…
Piet
  • 2,188
  • 5
  • 19
  • 30
105
votes
7 answers

Type hinting in PHP 7 - array of objects

Maybe I missed something but is there any option to define that function should have argument or return for example array of User objects? Consider the following code:
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
103
votes
2 answers

Is there a way to extend a trait in PHP?

I want to use functionality of an existing trait and create my own trait on top of it only to later apply it on classes. I want to extend Laravel SoftDeletes trait to make SaveWithHistory function, so it will create a copy of a record as a deleted…
Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191
100
votes
5 answers

configure: error: Please reinstall the libzip distribution

I am getting this error, when trying to install Zip for PHP 7: pecl install zip yields the error configure: error: Please reinstall the libzip distribution I did not find anything related to this error. I tried apt-get install libzip but the…
Tobias Gassmann
  • 11,399
  • 15
  • 58
  • 92
99
votes
4 answers

PHP 7 interfaces, return type hinting and self

UPDATE: PHP 7.4 now does support covariance and contravariance which addresses the major issue raised in this question. I have run into something of an issue with using return type hinting in PHP 7. My understanding is that hinting : self means…
GordonM
  • 31,179
  • 15
  • 87
  • 129
98
votes
4 answers

Type hinting for properties in PHP 7?

Does php 7 support type hinting for class properties? I mean, not just for setters/getters but for the property itself. Something like: class Foo { /** * * @var Bar */ public $bar : Bar; } $fooInstance = new…
CarlosCarucce
  • 3,420
  • 1
  • 28
  • 51
92
votes
8 answers

How can I enable the MySQLi extension in PHP 7?

I have installed PHP 7 and MySQL 5.5.47 on Ubuntu 14.04 (Trusty Tahr). I have checked installed extension using: sudo apt-cache search php7-* It outputs: php7.0-common - Common files for packages built from the PHP source libapache2-mod-php7.0 -…
Mohammad Sayeed
  • 2,025
  • 1
  • 16
  • 27
91
votes
4 answers

Function return type hinting for an array of objects in PHP7

I am very happy with the new features in PHP 7. But I am confused on how to return an array of objects in PHP 7. For example, we have a class Item, and we want to return an array of objects of this class from our function: function getItems() :…
Robert Limanto
  • 2,068
  • 4
  • 17
  • 27
1
2 3
99 100