Questions tagged [php-8]

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

PHP 8 is the current major version of , released on 26 November 2020. It succeeded , which was the last release of PHP 7. There is a migration guide to assist with upgrading, and a complete list of changes.

New features

See a high-level overview of new features, or a more complete list as part of the migration guide.

Removed features

These features were deprecated in previous releases and removed in PHP 8.0

  • Old PHP 4-style constructors (methods with the same name as the class)
  • The ability to call non-static methods statically
  • The track_errors php.ini directive
  • The __autoload() magic function
  • The ability for the @ operator to silence fatal errors
  • "Leading numeric" strings (i.e. 345 == "345abc" now evaluates to false)
  • The use of the salt argument to password_hash()
  • The create_function() function
  • The each() function
  • The read_exif_data() function
  • The money_format() function
  • The use of array_key_exists() with objects

A complete list of removals and other backwards-incompatible changes can be found as part of the migration guide.

176 questions
0
votes
2 answers

Warning: Only the first byte will be assigned to the string offset

The following code was working just fine in PHP 7 so why am I seeing this warning in PHP 8? $str = 'xy'; $str[0] = 'bc';
Rain
  • 1,745
  • 1
  • 11
  • 23
0
votes
1 answer

What does this symbol mean "?->" in php, within an object or null value

Could you please explain what does the operator ?-> do in PHP, since I have this piece of code: $drive = $objDrive?->func?->getDriver()?->value;
Oscar Gallardo
  • 1,262
  • 3
  • 16
  • 38
-1
votes
0 answers

Guzzle Errors PHP 8 - $handle must be of type CurlHandle, null given

I'm moving from one server to a new one that's using PHP 8 on Apache2 on Debian. After installing Guzzle (composer require guzzlehttp/guzzle:^7.0) and pulling the files over, I'm receiving PHP Fatal Errors: [proxy_fcgi:error] AH01071: Got error 'PHP…
BNM
  • 19
  • 3
-1
votes
1 answer

"staudenmeir/laravel-adjacency-list ^1.0" package errors during installation

I install a package composer require staudenmeir/laravel-adjacency-list:"^1.0" but i got an the following errors. Problem 1 - staudenmeir/laravel-adjacency-list[v1.0, ..., 1.0.x-dev] require illuminate/database ~5.5.29|5.6.*|5.7.* -> found…
DUCE
  • 41
  • 1
  • 7
-1
votes
0 answers

Keep getting syntax error, unexpected token ";" " in PHP, but ";" is pretty much needed

I keep getting this error Parse error: syntax error, unexpected token ";" in C:\xampp\htdocs\test\7-mysql\index.php on line 9 (line 9 is "header("Location: loggedinpage.php");") This is my code in PHP 8.0.5:
-1
votes
1 answer

upgrading from PHP 7.0 to PHP 8.0

There is a issue in my all projects. It was working fine and perfect in PHP 7.0 but in PHP 8.0 it is showing error. In I was creating POST and GET variables like this (without single quote): 1) $_POST[dob] 2) $_GET[id] 3) INSERT INTO company…
-1
votes
1 answer

No route found for "GET /user" on Symfony 5 in docker container

To create a web-service, I create a new project with a container php-nginx for web-server, postgresql-13 for db, so I create my Dockerfile based on FROM php:7.4-fpm-alpine for php-nging container and docker-compose.yml for my…
bcag2
  • 1,131
  • 1
  • 8
  • 20
-1
votes
1 answer

Fatal error Uncaught Error: Call to undefined method WP_Error

Error message Fatal error: Uncaught Error: Call to undefined method WP_Error::resize() in C:\Users\User\Documents\xampp\htdocs\WordPress1\wp-content\themes\elina\framework\php\PeTheme\PeThemeImage.php:144 Stack trace: #0…
-1
votes
2 answers

PHP8 compare 0 with an empty string, what is the logic behind that

in PHP 8 why comparing 0 with an empty string, surprised me. I can't understand the logic. $a = 0; $b = ""; echo ($a == false) ? "yes a is False
" : "no
"; echo ($b == false) ? "yes b is False
" : "no
"; echo ($a == $b) ? "yes a…
Raskul
  • 447
  • 1
  • 12
-1
votes
1 answer

Making an image gallery but why do I have this error?

I'm having some errors with my file. Does anyone know what I did wrong? Error: syntax error, unexpected ':', expecting ')' in C:\wamp65\www\Php2\01_gallery.php on line 5 It gives above error when I load the page and the error comes from this…
SmpLife
  • 21
  • 2
-1
votes
1 answer

Error in packages while installing with PHP 8 using composer

I want to run laravel application which I had clone from my Gitlab repository. However, while running composer update command throwing me below error. Environment: php -v: PHP 8.0.1 composer --version: 2.0.9 I understand that PHP 8 doesn't provide…
Maqsud
  • 611
  • 1
  • 1
  • 11
-1
votes
1 answer

Composer failing with Signal 9

I'm puzzled about this Composer failure. Can anyone help? The only things I've seen about "signal 9" have to do with resource limitations, which I do not have. It looks like a require() is failing? I have a new M1-based macbook air, running PHP…
SMac
  • 29
  • 2
  • 3
-1
votes
1 answer

laravel valet not works after php8 upgraded

I just upgraded brew .. brew update // or brew upgrade .. and suddenly php 8 has installed on my macbook. After that, Laravel valet does not work.. I wonder if I have to remove php8 and reinstall php 7.x . Or maybe I can get how to fix this…
bingglex
  • 65
  • 1
  • 4
-1
votes
3 answers

How to check if a variable is zero or empty in both PHP 7 and 8?

MySQL with PHP can sometimes be annoying when decimals are returned as strings. What is a minimalistic way to determine if a variable is empty? By empty I mean any the following: null, (bool)false, (int)0, (float)0.00, (string)"", (string)"0",…
tim
  • 1,819
  • 2
  • 21
  • 37
-1
votes
1 answer

How to check PHP version using only syntax checker output

I want each member of my team to (reliably) report which version of PHP they are checking their syntax against. Members of my team have various operating systems, IDEs and text editors, with various PHP syntax checker plugins, and multiple php…
Liam
  • 17,556
  • 23
  • 76
  • 110
1 2 3
11
12