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
-2
votes
0 answers

Php 8.0 and Notice... warning

I believe php 8 add a major change : "notice" (if a variable is not set) is now a warning. Is there a way, to change this behaviour ? I do believe a warning is too much for a "isset" statement. I don't talk about my own, 99% I use isset (or empty),…
David N
  • 114
  • 1
  • 7
-2
votes
1 answer

Fatal error: Uncaught TypeError: mysqli_fetch_assoc()

My Codes: $zaman = '%'.date('Y-m-d').'%'; $Sorgu = mysqli_query($link, "SELECT COUNT( * ) AS sayi, ip FROM visitors WHERE zaman LIKE '$zaman' AND sayfa LIKE '%admin%' GROUP BY ip ORDER BY sayi ASC"); …
Mert
  • 139
  • 7
-2
votes
2 answers

Composer install & update issue (requires php ^7.0 -> your php version (8.0.3))

We are starting to use PHP 8 on new projects. But we are also migrating old projects to the new PHP 8. Problems occur when installing dependencies. Because PHP 8 is relatively new, there are still many third-party packages that depend on older…
Martin Osusky
  • 583
  • 2
  • 12
-2
votes
3 answers

How to create javascript like object in php

Let's say, I have a javascript object array like the following. let users = [ { 'id' => 1, 'name' => 'John', 'amount' => 1000, }, { 'id' => 2, 'name' =>…
Pranta
  • 518
  • 5
  • 15
-2
votes
1 answer

PHP EACH ELEMENT IS NOT SUPPORT IN PHP8

Is not working on php8 each function is removed on php8 list($orig,$values) = each($where); Full code: if ($custom = apply_filters("pe_theme_metabox_$type",$pmboxes)) { //print_r(array_keys(PeGlobal::$config["metaboxes-view"])); $keys =…
-2
votes
1 answer

best way to prevent sql injection in php 8

What is the best way to prevent SQL-injection in PHP 8? the only way that I know is Prepared statement. https://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php I want to know is there any other way to prevent SQL-injection in…
Raskul
  • 447
  • 1
  • 12
-2
votes
1 answer

Getting PHP 8 errors even though not using PHP 8

a few weeks back I setup PHP 8 but hit some issues in projects so reverted back to 7.4. However, a few of my projects are broken and the errors I'm getting all seem linked to PHP 8. An example is "Fatal error: Uncaught ArgumentCountError:…
Lovelock
  • 6,609
  • 15
  • 71
  • 162
-2
votes
1 answer

Can anyone find and help me what is this error is about?

@foreach($id_cards as $id_card) @endforeach error…
-2
votes
1 answer

How does null safe operator works in php 8?

PHP introduced null operator in PHP8. What is the benefit of using Null operator. And how does it work? Will be delightful in anyone enlighten my knowledge.
-3
votes
1 answer

How to fix laravel/ui error to upgrade Laravel after upgrading PHP to 8.0

I'm trying to upgrade Laravel after PHP was upgraded to 8.0 with brew on macos, but I'm getting the errors below. How should I fix it ? $ composer update …
DevonDahon
  • 4,134
  • 2
  • 37
  • 57
-7
votes
2 answers

How to perform case insensitive str_contains?

I have plenty of if(mb_stripos($hay, $needle) !== false) in my code. How do I replace it with str_contains()? For example, I have this helper function in my code:
Dharman
  • 21,838
  • 18
  • 57
  • 107
1 2 3
11
12