php-8.1 Questions
3
Solved
I am trying to enable sqlsrv drivers for php8.1 on Ubuntu 20.0. It is not showing the extension in phpinfo().
When trying to check the sqlsrv module with commmand php -m, the output is like this:
...
Quean asked 13/11, 2022 at 15:31
2
Is there any way, using reflection or otherwise, to change a readonly property that has already been set?
We sometimes do that in tests, and we don't want to avoid using readonly props just for tes...
Hon asked 18/3, 2022 at 17:12
4
Solved
I am just getting started on upgrading my code to be php 8.1 compatible. I have many pieces of code where I am passing potentially null values to internal functions.
if (strlen($row) > 0) {
......
4
Solved
I have basic enum
enum Fruit
{
case APPLE;
case ORANGE;
case BANANA;
}
and some function that uses typing with that enum:
function eatFruit (Fruit $fruit)
{
// do stuff
}
and variable with un...
9
Solved
PHP 8.1 is almost getting released, including support for Enumerations. I was testing some of the enum functionality and couldn't find much documentation about it. Hence my question: how do I get a...
3
I have a project that is using DDEV to run an instance with PHP 8.1.
I needed to introduce the pdo_sqlsrv extension to the package, so I added a Dockerfile in the .ddev/web-build/ directory that in...
3
Solved
I am trying to install the phpize on Ubuntu 20.04 PHP 8.1
I tried following commands but no luck
sudo apt-get install php8.0-dev
E: Unable to locate package php8.0-dev
E: Couldn't find any packag...
4
Solved
Is there a type hint in PHP 8.3 which allows using ExampleClass[] for declaring it is an array of objects of the class ExampleClass?
In my specific case, ExampleClass is called Task
What I want bu...
Desultory asked 25/2, 2022 at 11:30
14
Solved
PHP 8.1 has deprecated passing null as parameters to a lot of core functions. My main problem is with functions like htmlspecialchars(php) and trim(php), where null no longer is silently converted ...
Anthea asked 1/4, 2022 at 13:0
5
I´m trying to create an php 8.1 enum from a dynamic name. Seems not to be possible. So given an enum
enum Foo {
case bar;
}
The following works of course: Foo::bar While this doesn´t:
$name = &qu...
4
Solved
How can I tell if a variable is of type enum?
I have installed PHP 8.1 on my Ubuntu 20.04. I'm testing the new "enum" types.
Is something like that possible?
is_enum($var)
gettype($var) =...
2
Solved
Versions :
PHP : 8.1
PHPUnit : 9.5.21
Symfony 6.1
When the following test is run by PhpUnit, I get an error about the session not being able to be started. Does anyone have an idea of the problem...
2
I'm running codeigniter 4.1.5 and php 8.1.0 and when i try to input data this is the error i got
Uncaught ErrorException: strtolower(): Passing null to parameter #1 ($string) of type string is depr...
Congregationalism asked 9/12, 2021 at 5:24
3
We are upgrading to PHP 8.1. A new feature is that an undefined array key throws a warning.
Unfortunately this interferes with the ability to easily use associative arrays such as $_SESSION v...
Ruelas asked 7/2, 2022 at 20:40
3
Is it possible to run Wordpress on PHP 8.1 right now? I have installed PHP 8.1 in XAMPP, but I can't get Wordpress to work. I get this error message:
[23-Nov-2021 18:44:43 UTC] PHP Fatal error: Un...
2
Solved
In PHP 8.1, the following code, which worked in previous versions:
class Example implements Countable {
public function count() {
return 42;
}
}
Raises a deprecation notice:
Deprecated: Return...
4
Solved
php 8.1 - explode(): Passing null to parameter #2 ($string) of type string is deprecated [duplicate]
Coming across some deprecated errors with 8.1 I want to address.
PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in...
//explode uids into an ar...
4
Solved
After updating PHP 7.4 to PHP 8.1 RC5, PHP has stopped working on my machine and produces following error:
PHP Warning: PHP Startup: ^(text/|application/xhtml+xml) (offset=0): unrecognised compile...
3
I am wondering why it is not possible to provide an __toString implementation for enum.
IDE says "Enum may not include '__toString'". However it was the first thing I thought about once I...
1
Solved
Since PHP 8.1 the native support for readonly properties arrived. But we already have constants with visibilities.
Please help me to answer these two questions:
Which differences are between using...
Tribe asked 15/5, 2022 at 12:27
4
Solved
I search for a simple solution to get the case of an enum by a string.
There are BackedEnums. For example:
<?php
enum Status: string
{
case OK = "OK";
case FAILED = "FAILED"...
2
Solved
I want to iterate over enum:
enum Shapes
{
case RECTANGLE;
case SQUARE;
case CIRCLE;
case OVAL;
}
I get Shapes const not defined if I do this:
foreach (Shapes as $shape) { }
The best solution...
2
Solved
My Code:
namespace App\Enum;
enum HomeStatus: string
{
case RENT = 'rent';
case MOVE_IN = 'move_in';
case SOLD = 'sold';
case COMING_SOON = 'coming_soon';
}
The code above is executing and wo...
Gymnosperm asked 7/1, 2022 at 13:2
1
We are upgrading PHP to version 8.1. Using MS Sql Server DB. It all seems to work correctly but I see repeated messages in the log file:
[03-Feb-2022 11:51:18 America/New_York] PHP Deprecated: Aut...
Intention asked 8/2, 2022 at 14:9
1
Solved
PHP 8.1 introduces readonly class properties. For example, before I would write:
class User
{
public string $name;
public function __construct(string $name) {
$this->name = $name;
}
publi...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.