Questions tagged [php-7.4]

For questions specific to the usage and features of version 7.4 of PHP. When using this tag also include the more generic [php] tag.

505 questions
203
votes
1 answer

Array and string offset access syntax with curly braces is deprecated

I've just updated my php version to 7.4, and i noticed this error pops up: Array and string offset access syntax with curly braces is deprecated here is part of my code which is triggering the above error: public function getRecordID(string…
Pezhvak
  • 9,633
  • 7
  • 29
  • 39
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
106
votes
2 answers

Message: Trying to access array offset on value of type null

I'm getting this error on multiple occasion in a script (invoiceplane) I have been using for a few years now but which hasn't been maintained unfortunately by its creators: Message: Trying to access array offset on value of type null My server has…
vespino
  • 1,714
  • 3
  • 15
  • 28
69
votes
6 answers

Update PHP to 7.4 macOS Catalina with brew

I try to update my PHP version to 7.4 on macOS Catalina with brew. I did brew install php@7.4 If I check my version php -v, I still see the old version PHP 7.3.11? What do I have to do? Update: After brew doctor I get: Warning: Homebrew's sbin was…
meez
  • 3,783
  • 5
  • 37
  • 91
68
votes
6 answers

What is null coalescing assignment ??= operator in PHP 7.4

I've just seen a video about upcoming PHP 7.4 features and saw this new ??= operator. I already know the ?? operator. How's this different?
Mike Doe
  • 16,349
  • 11
  • 65
  • 88
60
votes
2 answers

PHP 7.4 deprecated get_magic_quotes_gpc function alternative

I am encountered with the situation where one of my old code is using get_magic_quotes_gpc() which is deprecated in the latest PHP version 7.4.* Currently, I have something like this. Add Slashes return get_magic_quotes_gpc() ? addslashes($string) :…
Code Lover
  • 8,099
  • 20
  • 84
  • 154
50
votes
2 answers

Trying to access array offset on value of type bool in PHP 7.4

I just upgraded my server's PHP version to PHP 7.4.1 and now getting this error: Notice: Trying to access array offset on value of type bool in public static function read($id) { $Row = MySQL::query("SELECT `Data` FROM `cb_sessions` WHERE…
anjanesh
  • 3,771
  • 7
  • 44
  • 58
35
votes
4 answers

Unable to install PHP 7.4 on Ubuntu 16.04 even with Ondrej PPA repository in apache2

I am trying to install PHP 7.4 on Ubuntu 16.04 for Apache2 server. To install the 7.4 version, I used PPA ondrej repository as follows: sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt update sudo apt…
Santosh Dangare
  • 685
  • 1
  • 4
  • 15
24
votes
1 answer

Is type callable supported with typed properties?

I searched reasons for this but wasn't able to find any reason for this. I tried to create a typed property with the type 'callable'. But PHP gives me a fatal error "cannot have type callable". In the RFC, it is not mentioned, that callable is not…
mscho
  • 860
  • 7
  • 16
22
votes
1 answer

(??=) Double question mark and an equal sign, what does that operator do?

Once I stumbled with php7 code with operator ??=. I tried to search, what it clearly does, but could not find easily. I tried to read out the php operators and even most official resources have all operators description and even compound operators…
Green Joffer
  • 580
  • 1
  • 4
  • 16
21
votes
3 answers

How to use arrow functions in PHP?

I got to know about arrow functions in PHP 7.4. I tried using them like { return $num + 1; } echo $arrowfunction(); Because I saw the => operator in the pull request. Just like javascript. I expected '2'…
weegee
  • 3,256
  • 2
  • 18
  • 32
18
votes
3 answers

Trying to access array offset on value of type null

Migrating from php 7.1 to 7.4. We have like 500 functional tests for an API, and some of them started to fail with an error after the migration was complete. These tests were passing before everywhere, and now fail everywhere - not all, just…
Random Dude
  • 872
  • 1
  • 9
  • 24
17
votes
2 answers

Check in PHP 7.4 whether a property is really initialized or not

I want to check in PHP 7.4 whether a property is really initialized or not. Setting the property to null means it is initialized with null. I can not use isset because it returns false even when it is set to null. I can not use property_exists…
Heiko Jerichen
  • 171
  • 1
  • 5
15
votes
5 answers

Twig problem with php 7.4 in write variable

I using php7.3 on my project and use Twig in this project After upgrade my php version to 7.4 i have some error in twig rendering. I set some html class by Twig variable For example: php
Biqarar
  • 195
  • 1
  • 6
1
2 3
33 34