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
45
votes
9 answers

Linux - PHP 7.0 and MSSQL (Microsoft SQL)

Yes, I know that PHP 7.0 removed the extensions needed to connect to MSSQL. FreeTDS was my option prior to PHP 7.0 but now there really is no obvious upgrade path for those needing to still connect to MSSQL. Stupid question, but given that MSSQL is…
Donavon Yelton
  • 1,227
  • 3
  • 15
  • 24
43
votes
6 answers

PHP rand() vs. random_int()

As php.net indicates: random_int() function Generates cryptographically secure pseudo-random integers. But, Can someone explain whats the difference between rand() & random_int()? Can I use random_int() instead of rand() when only requiring a random…
behkod
  • 2,647
  • 2
  • 18
  • 33
43
votes
9 answers

How can I install mcrypt under PHP7? Laravel needs it

Since Laravel4 requires mcrypt extension, and PHP7 doesn't seem to have mcrypt extension, is there any workaround for this to work?
Bishal Paudel
  • 1,896
  • 2
  • 21
  • 28
41
votes
2 answers

How to select PHP version 5 and 7 per virtualhost in Apache 2.4 on Debian?

Would it be possible to run PHP 7 and PHP 5 simultaneously in Apache 2.4 on Debian 9? I would like to be able to select the PHP version I wish to use per virtualhost. I believe this would be useful considering that some of my websites still use…
Z0q
  • 1,689
  • 3
  • 28
  • 57
40
votes
3 answers

DateTimeImmutable vs DateTime

The 2 classes DateTime and DateTimeImmutable implement the same interface DateTimeInterface. Therefore I want to know : What is the difference between these 2 classes DateTime and DateTimeImmutable?
hbgamra
  • 749
  • 1
  • 6
  • 18
39
votes
2 answers

Are scalar and strict types in PHP7 a performance enhancing feature?

Since PHP7 we can now use scalar typehint and ask for strict types on a per-file basis. Are there any performance benefits from using these features? If yes, how? Around the interwebs I've only found conceptual benefits, such as: more precise…
igorsantos07
  • 4,456
  • 5
  • 43
  • 62
39
votes
5 answers

Anonymous classes in PHP 7

Where can i use and should i use anonymous classes that are presented in PHP 7 ? I can't find a use case for them. $message = (new class() implements Message { public function getText() { return "Message"; }});
Eligijus
  • 634
  • 1
  • 6
  • 15
38
votes
4 answers

What is the purpose of the question marks before type declaration in PHP7 (?string or ?int)?

Could you please tell me how is this called? ?string and string Usage example: public function (?string $parameter1, string $parameter2) {} I wanted to learn something about them but I cannot find them in PHP documentation nor in google. What is…
divHelper11
  • 2,090
  • 3
  • 22
  • 37
35
votes
12 answers

Installing the PHP 7 MongoDB Client/Driver?

I am very eager to start working with PHP 7 however one issue is getting in the way... I primarily use MongoDB for the database, and the problem is that I don't know how to install the MongoDB driver/client for PHP 7. My current installation is PHP…
Vladimir Fazilov
  • 381
  • 1
  • 4
  • 6
34
votes
6 answers

Have trouble installing phpmyadmin on PHP7 Apache/2.4.7 (Ubuntu)

I installed PHP7 today with sudo add-apt-repository ppa:ondrej/php-7.0 sudo apt-get install php7.0-cli php7.0-common libapache2-mod-php7.0 php7.0 php7.0-mysql php7.0-fpm after this, I got 403 forbidden error when I tried to access phpmyadmin. then…
Mister M
  • 1,539
  • 3
  • 17
  • 37
33
votes
10 answers

How to install redis extension for php 7

Referred this link https://anton.logvinenko.name/en/blog/how-to-install-redis-and-redis-php-client.html And done following steps PhpRedis for PHP 7 (Skip it if you have different PHP version) Install required package apt-get install…
Prashant G Patil
  • 927
  • 1
  • 8
  • 22
30
votes
16 answers

php 7 php.ini upload_max_filesize not working

I have read many solutions on internet , but still cannot change upload_max_filesize value (upload_max_filesize always = 2M ) here is my loaded php.ini in phpinfo() : Configuration File (php.ini) Path /etc/php/7.0/apache2 Loaded…
CuongDC
  • 634
  • 1
  • 7
  • 16
28
votes
2 answers

Does codeigniter 3 support PHP 7?

In the docs of CodeIgniter it states, PHP version 5.4 or newer is recommended. I looked on forums etc. and wasn't able to find a definitive yes/no on this, even though the above sentence implies a 'yes', I wasn't sure if that extended to the (now…
Jonathan Clark
  • 1,180
  • 1
  • 8
  • 26
28
votes
6 answers

Correct way to handle PHP 7 return types

I'm busy creating an application and i want to use the PHP 7 return types. Now I read on php.net that it was a design decision that it is not allowed to return null when a return type is defined. What is the correct way too handle this? One option…
S.Pols
  • 3,414
  • 2
  • 21
  • 42
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