Title: PHP warning with PHP 8.x
Last modified: January 6, 2023

---

# PHP warning with PHP 8.x

 *  Resolved [markisu72](https://wordpress.org/support/users/markisu72/)
 * (@markisu72)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/php-warning-with-php-8-x/)
 * Hi,
 * on PHP 8.x I can produce
 * PHP message: PHP Warning: Undefined array key “length” in /home/wp/disk/wordpress/
   wp-content/plugins/insert-headers-and-footers/includes/class-wpcode-snippet-execute.
   php(268) : eval()’d code on line 25
 * when running this PHP snippet:
 * class myClass {
   }new myClass;
 * on WooCommerce product pages (only).
 * Could you help me find out, what’s the issue (in real life, the code is for sure
   different, but I was able to narrow it down).
 * Thanks
 * Markus

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Mircea Sandu](https://wordpress.org/support/users/gripgrip/)
 * (@gripgrip)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/php-warning-with-php-8-x/#post-16348181)
 * Hi [@markisu72](https://wordpress.org/support/users/markisu72/),
 * From the code you have shared there’s no mention of the “length” key mentioned
   in the notice. That notice comes up when you are trying to access an array key
   that doesn’t exist so I would look at any other snippets that might be using 
   the key “length” if you are still getting this notice with just the code you 
   mentioned above.
 * You mentioned it’s only happening on WooCommerce product pages so if you have
   any WooCommerce-related snippets that’s the first place I would look at, you 
   should be able to adjust the code adding a check for the “length” key.
 * This is not related to the PHP version or specific to WPCode as it seems to be
   happening when executing a snippet of code.
 * If you can share more of the code of the snippets you have active on your site
   I’d be happy to help pinpoint the issue, please reach out using the form at [https://wpcode.com/contact ](https://wpcode.com/contact)
   if you want to share code privately.
 *  Thread Starter [markisu72](https://wordpress.org/support/users/markisu72/)
 * (@markisu72)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/php-warning-with-php-8-x/#post-16348229)
 * Hi [@gripgrip](https://wordpress.org/support/users/gripgrip/)
 * thanks for your quick reply.
   I’m too tired today.The error is sitting in front
   of the screen 😉BestMarkus

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP warning with PHP 8.x’ is closed to new replies.

 * ![](https://ps.w.org/insert-headers-and-footers/assets/icon-256x256.png?rev=2758516)
 * [WPCode - Insert Headers and Footers + Custom Code Snippets - WordPress Code Manager](https://wordpress.org/plugins/insert-headers-and-footers/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-headers-and-footers/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-headers-and-footers/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-headers-and-footers/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-headers-and-footers/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-headers-and-footers/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [markisu72](https://wordpress.org/support/users/markisu72/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/php-warning-with-php-8-x/#post-16348229)
 * Status: resolved