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
27
votes
1 answer

PHP 7 changes to foreach: Can I still delete items in they array on which I'm iterating?

The PHP 7 Backward-Incompatible Changes Document says the following about foreach: When used in the default by-value mode, foreach will now operate on a copy of the array being iterated rather than the array itself. This means that changes to the…
userlite
  • 479
  • 1
  • 5
  • 13
27
votes
2 answers

POST request to PHP7 with chunked encoding does not properly return result

I'm sending a POST request from a client (tested with curl and custom nodejs script) and don't get the response properly back. The whole thing works fine with PHP 5.6. Environment The whole thing is reduced as much as possible: everything running…
mark
  • 6,308
  • 8
  • 46
  • 57
27
votes
7 answers

How install apcu as php7 extension on debian

I have seen this tutorial for ubuntu. http://thereluctantdeveloper.com/2015/12/quick-and-dirty-php-70-set-up-on-ubuntu-1404-with-apcu It's not clear for me after step(git clone). I need apcu extension for my app to perform faster. Please guide…
ns dns
  • 271
  • 1
  • 3
  • 4
27
votes
7 answers

What is the status of the MongoDB extension for PHP7?

PHP7 is gaining a lot of attention lately, promising great performance and a more mature language. Version 7.0.0-alpha is out. We are just starting to rework our core application, which uses MongoDB as data source. I am wondering if there is any…
markz
  • 1,766
  • 2
  • 14
  • 15
26
votes
4 answers

WARNING: Module ini file doesn't exist under /etc/php/7.0/mods-available

I have uninstalled php7 and all its modules from ubuntu, and when I try to reinstall the modules, I get the following error for each php module, and although the module is installed, because of this error, it is not activated and I cannot use…
TheDevWay
  • 1,363
  • 1
  • 16
  • 45
26
votes
5 answers

Memcache for PHP7 on Windows?

Does any one know about a Memcache version that supports PHP7 on Windows? Memcache is working great for PHP 5.6 (on Windows), but I cannot find the version for PHP7.
Jens Kirk
  • 526
  • 1
  • 5
  • 19
25
votes
5 answers

Laravel Public url for storage files

I want to retrieve public url for all the files stored using storage::putFile('public/spares'); So, this is the issue I'm using storage::files('public/spares'); but it provides this output from laravel storage…
Daniel Euchar
  • 1,740
  • 5
  • 28
  • 45
25
votes
4 answers

Parse error: Invalid numeric literal

I have the following error while running this code below: Code: Error: Parse error: Invalid numeric literal. Why this issue occurred and how do i solve this?
Rana Ghosh
  • 4,514
  • 5
  • 23
  • 40
25
votes
1 answer

Doctrine manyToMany return PersistentCollection instead of ArrayCollection

I'm working with Symfony 3.1 and Doctrine 2.5. I setup a manyToMany relationship as I always do : manyToMany: placeServices: targetEntity: Acme\MyBundle\Entity\PlaceService joinTable: name:…
Thomas Piard
  • 1,209
  • 2
  • 15
  • 25
24
votes
2 answers

When using PHP7, is it necessary to document methods with PHPDoc?

In PHP7, when a method sets a given parameter type and result type, is it necessary to document them again in the PHPDoc ? Since function foo(string $text): bool { return true; } Is equivalent to /** * @param string $text * @return bool …
Marc Brillault
  • 1,902
  • 4
  • 21
  • 41
24
votes
4 answers

php7 void return type not working?

I have a problem with return types in php7, specially "void". it works with all other types, int, string, null, bool, class objects. but when i use void it expecting me to return an instance of object void but in reality it should not expect any…
nSams Dev
  • 687
  • 2
  • 8
  • 21
24
votes
2 answers

PHP 7 Performance

I've tried to reproduce this benchmark which compares PHP 7 with older versions on a Wordpress server: http://talks.php.net/oz15#/wpbench My configuration is nearly the same, the server has an i7, SSD, 16GB RAM and debian. The server software is…
Timo Denk
  • 575
  • 1
  • 6
  • 21
23
votes
2 answers

Download PhpSpreadsheet file without save it before

I'm using PhpSpreadsheet to generate an Excel file in Symfony 4. My code is: $spreadsheet = $this->generateExcel($content); $writer = new Xlsx($spreadsheet); $filename = "myFile.xlsx"; $writer->save($filename); // LINE I WANT TO AVOID $response =…
Genarito
  • 3,027
  • 5
  • 27
  • 53
23
votes
1 answer

Pass array to varargs function in php

I've got a varargs type method defined in PHP 7 function selectAll(string $sql, ...$params) { } The problem I'm running into is that sometimes I want to call this method when I already have an array, and I can't just directly pass an array variable…
Gargoyle
  • 9,590
  • 16
  • 80
  • 145
23
votes
2 answers

static return type in PHP 7 interfaces

Why is it not possible in PHP 7, to declare an interface with a static return type? Let's say I have the following classes: interface BigNumber { /** * @param BigNumber $that * * @return static */ public function…
BenMorel
  • 34,448
  • 50
  • 182
  • 322