php-7.4
What is null coalescing assignment ??= operator in PHP 7.4
From the docs: Coalesce equal or ??=operator is an assignment operator. If the left parameter is null, assigns the value of the right paramater to the left one. If the value is not null, nothing is done. Example: // The folloving lines are doing the same $this->request->data[‘comments’][‘user_id’] = $this->request->data[‘comments’][‘user_id’] ?? ‘value’; // Instead of repeating … Read more
Trying to access array offset on value of type bool in PHP 7.4
Easy with PHP ?? null coalescing operator return $Row[‘Data’] ?? ‘default value’; Or you can use as such $Row[‘Data’] ??= ‘default value’; return $Row[‘Data’];
PHP 7.4 deprecated get_magic_quotes_gpc function alternative
You need to remove every mention of this function from your code and do not replace it with anything else. get_magic_quotes_gpc() has been useless ever since PHP 5.4.0. It would tell you whether you have magic quotes switched on in the configuration or not. Magic quotes were a terrible idea and this feature was removed … Read more
Update PHP to 7.4 macOS Catalina with brew
You can find my similar answer for php@7.2. brew install php@7.4 brew link –force –overwrite php@7.4 brew services start php@7.4 export PATH=”/usr/local/opt/php@7.4/bin:$PATH” export PATH=”/usr/local/opt/php@7.4/sbin:$PATH”
Message: Trying to access array offset on value of type null [duplicate]
This happens because $cOTLdata is not null but the index ‘char_data’ does not exist. Previous versions of PHP may have been less strict on such mistakes and silently swallowed the error / notice while 7.4 does not do this anymore. To check whether the index exists or not you can use isset(): isset($cOTLdata[‘char_data’]) Which means … Read more
Why I am suddenly getting a “Typed property must not be accessed before initialization” error when introducing properties type hints?
Since PHP 7.4 introduces type-hinting for properties, it is particularly important to provide valid values for all properties, so that all properties have values that match their declared types. A property that has never been assigned doesn’t have a null value, but it is on an undefined state, which will never match any declared type. … Read more
What is the difference between fastcgi and fpm?
FPM is a process manager to manage the FastCGI SAPI (Server API) in PHP. Basically, it replaces the need for something like SpawnFCGI. It spawns the FastCGI children adaptively (meaning launching more if the current load requires it). Otherwise, there’s not much operating difference between it and FastCGI (The request pipeline from start of request … Read more
Array and string offset access syntax with curly braces is deprecated [duplicate]
It’s really simple to fix the issue, however keep in mind that you should fork and commit your changes for each library you are using in their repositories to help others as well. Let’s say you have something like this in your code: $str = “test”; echo($str{0}); since PHP 7.4 curly braces method to get … Read more