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
87
votes
5 answers

Is it possible to specify multiple return types on PHP 7?

I have some methods that can return one of two return types. I'm using a framework utilizing MCV so refactoring these few functions in particular is not appealing. Is it possible to declare the return type returning one or the other and failing on…
myol
  • 8,857
  • 19
  • 82
  • 143
82
votes
13 answers

PHP 7 simpleXML

I'm testing PHP7, and have a weird issue after a recent update. SimpleXML should be enabled by default, and my phpinfo page shows that it is available: However, the functions are not available:
user101289
  • 9,888
  • 15
  • 81
  • 148
75
votes
13 answers

PHP 7 RC3: How to install missing MySQL PDO

I am trying to setup webserver with PHP 7 RC3 + Nginx on Ubuntu 14.04 (for test purposes). I installed Ubuntu in Vagrant using ubuntu/trusty64 and PHP 7 RC 3 from Ondřej Surý (https://launchpad.net/~ondrej/+archive/ubuntu/php-7.0). I can not find…
SmxCde
  • 5,053
  • 7
  • 25
  • 45
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
72
votes
20 answers

PHP 7 with phpmyadmin gives lots of Deprecation Notices

I have Ubuntu 16.04 LTS running with PHP7 and phpmyadmin installed. However, I get a lot of deprecation notices like: Deprecation Notice in ./../php/php-gettext/streams.php#48 Methods with the same name as their class will not be constructors in a…
yoano
  • 1,466
  • 2
  • 16
  • 20
71
votes
6 answers

install php70-gd on ubuntu

Recently the new php7 has been released. However, when I am trying to install the gd package, the library can not be found. I have tried through sudo apt-get install php70-gd and sudo apt-get install php70-php-gd Does anybody have an idea if gd…
xfscrypt
  • 16
  • 5
  • 28
  • 59
68
votes
3 answers

Enabling 'strict_types' globally in PHP 7

I'm currently migrating my website from PHP5 to PHP7, and I've started using the strict typing feature that was added. However this requires me to begin all files with the following line:
Paradoxis
  • 4,471
  • 7
  • 32
  • 66
68
votes
7 answers

Unterminated entity reference in PHP

Here is my code: '); $products = $rss->addChild('products'); /// while($row = mysql_fetch_array($result)){ $product =…
mega6382
  • 9,211
  • 17
  • 48
  • 69
64
votes
2 answers

PHP 7 and strict "resource" types

Does PHP 7 support strict typing for resources? If so, how? For example: declare (strict_types=1); $ch = curl_init (); test ($ch); function test (resource $ch) { } The above will give the error: Fatal error: Uncaught…
Phil
  • 2,008
  • 1
  • 17
  • 23
64
votes
1 answer

"Call to undefined function mysql_connect()" after upgrade to php-7

After I upgraded php5 to php7, I get an error 500 with PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() I put this into my apt sources in order to get php7 right now: deb http://packages.dotdeb.org jessie all deb-src…
bytecode77
  • 14,163
  • 30
  • 110
  • 141
61
votes
13 answers

PHP executable not found. Install PHP 7 and add it to your PATH or set the php.executablePath setting

I'm running windows 10 fresh copy and I just installed visual studio code. I was trying to develop a PHP project using VS Code. But I'm having trouble in setting up the environment. I saw a blog post and I downloaded the binary file of PHP 7 and…
Nifal Nizar
  • 895
  • 1
  • 8
  • 17
59
votes
5 answers

Void as return type

I was testing return types with PHP 7. I've created a simple script to test return types of PHP 7:
Daan
  • 12,099
  • 6
  • 34
  • 51
58
votes
4 answers

How to install php extension using pecl for specific php version, when several php versions installed in system?

I have installed both php5.6 and php7.0 from PPA on Ubuntu according to this manual http://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu But I didn't get how to install extensions using pecl for php5.6 or php7.0. For example I have already…
Oleg Abrazhaev
  • 2,751
  • 2
  • 28
  • 41
54
votes
2 answers

Colon after method declaration?

public function getRecords(int $id): array; Hi, can someone tell me what colon is doing here, in this method declaration inside PHP interface? Is this PHP 7 syntax and what array is meaning here? Method must return array or something else?
Vikast
  • 745
  • 1
  • 6
  • 15
52
votes
6 answers

C#'s null coalescing operator (??) in PHP

Is there a ternary operator or the like in PHP that acts like ?? of C#? ?? in C# is clean and shorter, but in PHP you have to do something like: // This is absolutely okay except that $_REQUEST['test'] is kind of redundant. echo…
kazinix
  • 28,987
  • 33
  • 107
  • 157