Title: PHP 8 Problem
Last modified: January 24, 2023

---

# PHP 8 Problem

 *  Resolved [ruthvant2022](https://wordpress.org/support/users/ruthvant2022/)
 * (@ruthvant2022)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/php-8-problem-6/)
 * I have this code linking to AFC gallery, it took me a while to make it work initially,
   it works perfectly in PHP 7.4, but causes a fatal error in PHP 8. Is there anything
   obvious to you that might do this?
 *     ```wp-block-code
       <!--Gallery Tag Lighbox Code//-->
       <div class="centerWidth popupGallery">
       <?php $images = get_field('pop_up_gallery');
       $size = 'square'; // (thumbnail, medium, large, full or custom size)
       $url = $image['url'];
       $title = $image['title'];
       $alt = $image['alt'];
       $caption = $image['caption'];
       if ($images): ?>
       <ul id="galleryList">
       <?php foreach($images as $image_id): 
       $content = '<li class="list-inline-item">';
       $content = '<a class="gallery_image" href="'. wp_get_attachment_url($image_id, $url).'">';
       $content = '<div class="galleryPhoto" style="background-image:url('. wp_get_attachment_url($image_id, $size) .');"></div>';
       $content = '<div class="galleryTitle"><p>'.wp_get_attachment_caption($image_id, $caption).'</p></div>';
       $content = '</a>';
       $content = '</li>';
       if ( function_exists('slb_activate') ){
       $content = slb_activate($content);
       }
       echo $content; ?>
       <?php endforeach; ?>
       </ul>
       <?php endif; ?>			
       </div>
       ```
   

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

 *  Plugin Author [Archetyped](https://wordpress.org/support/users/archetyped/)
 * (@archetyped)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/php-8-problem-6/#post-16408884)
 * Hi, what is the error message you are receiving when running under PHP 8? That
   should provide details on what the issue is.
 *  Thread Starter [ruthvant2022](https://wordpress.org/support/users/ruthvant2022/)
 * (@ruthvant2022)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/php-8-problem-6/#post-16411160)
 * **Fatal error**: Uncaught TypeError: Cannot access offset of type string on string
   in /home/tmpadev1co/public_html/wp-content/themes/Portico/single-properties.php:
   49 Stack trace: #0 /home/tmpadev1co/public_html/wp-includes/template-loader.php(
   106): include() #1 /home/tmpadev1co/public_html/wp-blog-header.php(19): require_once(‘/
   home/tmpadev1c…’) #2 /home/tmpadev1co/public_html/index.php(17): require(‘/home/
   tmpadev1c…’) #3 {main} thrown in **/home/tmpadev1co/public_html/wp-content/themes/
   Portico/single-properties.php** on line **49**
 * this is line 49
 * $url = $image[‘url’];
    -  This reply was modified 3 years, 4 months ago by [ruthvant2022](https://wordpress.org/support/users/ruthvant2022/).
 *  Thread Starter [ruthvant2022](https://wordpress.org/support/users/ruthvant2022/)
 * (@ruthvant2022)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/php-8-problem-6/#post-16411739)
 * Oh I’ve just tried it without the variable in brackets and it works! So only 
   need this
 *     ```wp-block-code
       <!--Gallery Tag Lighbox Code//-->
       <div class="centerWidth popupGallery">
       <?php $images = get_field('pop_up_gallery');
       $size = 'square'; // (thumbnail, medium, large, full or custom size)
       $url = $image['url'];
       $title = $image['title'];
       $alt = $image['alt'];
       $caption = $image['caption'];
       if ($images): ?>
       <ul id="galleryList">
       <?php foreach($images as $image_id): 
       $content = '<li class="list-inline-item">';
       $content = '<a class="gallery_image" href="'. wp_get_attachment_url($image_id, $url).'">';
       $content = '<div class="galleryPhoto" style="background-image:url('. wp_get_attachment_url($image_id, $size) .');"></div>';
       $content = '<div class="galleryTitle"><p>'.wp_get_attachment_caption($image_id, $caption).'</p></div>';
       $content = '</a>';
       $content = '</li>';
       if ( function_exists('slb_activate') ){
       $content = slb_activate($content);
       }
       echo $content; ?>
       <?php endforeach; ?>
       </ul>
       <?php endif; ?>			
       </div>
       ```
   
 *  Plugin Author [Archetyped](https://wordpress.org/support/users/archetyped/)
 * (@archetyped)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/php-8-problem-6/#post-16427341)
 * Something must be wrong with this forum’s formatting because the updated code
   block looks exactly the same as the code in your original post, but I’m glad 
   your issue was resolved 🙂
 * For future reference, checking [PHP’s website](https://www.php.net/) before upgrading
   to a different version is recommended, as they provide full details on the changes
   between versions, especially on changes that may affect compatibility with code
   written for older versions of PHP.

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

The topic ‘PHP 8 Problem’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/simple-lightbox.svg)
 * [Simple Lightbox](https://wordpress.org/plugins/simple-lightbox/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-lightbox/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-lightbox/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-lightbox/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-lightbox/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-lightbox/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Archetyped](https://wordpress.org/support/users/archetyped/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/php-8-problem-6/#post-16427341)
 * Status: resolved