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

Can't install php7 or php 7.1 with homebrew

I was following a couple links that had this same sequence, namely this example. I was unable to get it done successfully. Here is the output from terminal MacBook-Pro-4:/ SHennessy$ brew tap homebrew/dupes MacBook-Pro-4:/ SHennessy$ brew tap…
shenn
  • 859
  • 4
  • 17
  • 47
11
votes
1 answer

Problems to install php intl with Xampp (MacOs)

I´m installed Xampp in my Mac, the last version with Php7, all works fine, but in my Php proyect I´m using this function: numfmt_format_currency() I need install the intl, and edit the php.ini with this line: extension="intl.so” The problem is, I…
RichardMiracles
  • 2,032
  • 12
  • 28
  • 46
11
votes
3 answers

What happens with set_error_handler() on PHP7 now that all errors are exceptions?

On PHP5 it makes a whole lot of sense having both set_exception_handler() and set_error_handler() defined. However, on PHP7 all (most?) errors are now exceptions. So, what's the point on defining both handlers, if even errors would pass by the…
igorsantos07
  • 4,456
  • 5
  • 43
  • 62
11
votes
1 answer

Will type declaration in functions make my code perform better?

PHP 7 is slowly unrolling and people start working with it, and so am I. One of the new features in PHP7 is that you can give functions a type declaration for the inputs, and a type declaration for the result. Example, one input must be a string,…
Martijn
  • 15,791
  • 4
  • 36
  • 68
11
votes
2 answers

How to catch the "Call to undefined method" error in PHP 7?

I use my own simple error handling and can actually catch&log everything I need. But now I need to catch an error with try{}catch(){}. The error, that I expect occurring sometimes at that place, is the "Call to undefined method" error. I can catch…
automatix
  • 14,018
  • 26
  • 105
  • 230
11
votes
2 answers

Difference between Error and ErrorException in PHP 7

In the documentation for PHP 7, I noticed that two predefined exceptions, Error and ErrorException are almost exactly the same, with ErrorException having the additional $severity property and Error only being introduced in PHP 7 while…
akukas
  • 555
  • 1
  • 6
  • 11
11
votes
4 answers

New lines and tabs in json_decode() (PHP 7)

My code using json_decode() worked correctly with PHP 5.6. After migration to PHP 7.0, json_decode() returns NULL and json_last_error() tells me that my error is: Control character error, possibly incorrectly encoded After debugging, I found out…
Robo Robok
  • 21,132
  • 17
  • 68
  • 126
11
votes
1 answer

PHP7 cli vs php-fpm

I'm running php behind nginx with php-fpm and cron tasks to php binary (/usr/bin/php). I've found an inconsistency - the same script outputs different results when I run it through php binary and through fpm. NOTE This only applies to PHP7. On…
galchen
  • 5,252
  • 3
  • 29
  • 43
10
votes
11 answers

WordPress Editor not updating files: Unable to communicate back with site to check for fatal errors

I've run into an issue with updating the header.php file in a WordPress website. Firstly, I tried updating the file manually through C-Panel -> File Manager. The code appears to stay in the file, but when you view the page source in incognito mode…
nickhiebertdev
  • 525
  • 1
  • 6
  • 21
10
votes
2 answers

Wampserver not changing the PHP version

I have Wampserver 3.0.6 32 bit installed and it comes with PHP versions 5.6.25 and 7.0.10. When I switch from 5.6.25 to 7.0.10 from the server tray icon it does not update the actual php version my pc is using. I can test this with running this in…
user3574492
  • 6,225
  • 9
  • 52
  • 105
10
votes
3 answers

How to type decimal in PHP?

I keep a field in the database that has a decimal type. How can I type this? public function getPrice() : decimal { $temp = 123.45; return $temp; } It is not working, because return: Fatal error: Uncaught TypeError: Return value of…
jilo
  • 103
  • 1
  • 1
  • 5
10
votes
5 answers

Serving PHP files as downloads, instead of executing them

I recently installed nginx and php 7.0.16 in my machine, but for some reason nginx downloads php files, rather than executing them. I've already spent couple of days and implemented all solutions available online, but all in vain. My nginx.conf is:…
Ravi Singh
  • 431
  • 3
  • 10
  • 23
10
votes
1 answer

Can PHP7 opcached files be distributed without source code?

PHP7 offers a bytecode caching mechanism called opcache. I'd like to know if there is any way to distribute and run the "opcached" version of a PHP script (.bin file extension) without distributing its source code. (I enabled the opcache.file_cache…
dasup
  • 3,815
  • 1
  • 16
  • 25
10
votes
3 answers

How do I get the earliest possible datetime in php?

My understanding is that datetimes in php are represented as the number of milliseconds after a certain date (some time in 1960 I think?). How to I construct a datetime that represents the earliest allowable date in php? An example possible syntax…
Allen More
  • 858
  • 3
  • 14
  • 25
10
votes
1 answer

Unexpected behaviour in foreach while looping and unsetting in ArrayObject. An item is ignored

(examples at the bottom!!!) we have just upgrade our backend to PHP7 and after that, we have found a bug in our code related to an ArrayObject. The code just loops over a copy of an Object (type native ArrayObject). The foreach iterates by…
Daniel Nieto
  • 131
  • 6