Title: PHP7 Error
Last modified: March 2, 2017

---

# PHP7 Error

 *  [bpalombo](https://wordpress.org/support/users/bpalombo/)
 * (@bpalombo)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/php7-error-11/)
 * I’m looking to move up to PHP7. After completing a scan I got the following error
   and I’m wondering if there are plans to get this plugin ready for 7.
 * FILE:/wp-content/plugins/shortcodes-ultimate/inc/core/tools.php
    ————————————————————————————————————————-
   FOUND 1 ERROR AFFECTING 1 LINE ————————————————————————————————————————- 681 
   | ERROR | Using ‘break’ outside of a loop or switch structure is invalid and 
   will throw a fatal error since PHP 7.0 ————————————————————————————————————————-

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

 *  [YoWangdu](https://wordpress.org/support/users/yowangdu/)
 * (@yowangdu)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/php7-error-11/#post-8871283)
 * Same here. 681 | ERROR | Using ‘break’ outside of a loop or switch structure 
   is invalid and will throw a fatal error since PHP 7.0 Can someone help about 
   this issue?
    Thank you,
 * Lobsang
    -  This reply was modified 9 years, 2 months ago by [YoWangdu](https://wordpress.org/support/users/yowangdu/).
 *  [Millermore](https://wordpress.org/support/users/trentonm11/)
 * (@trentonm11)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/php7-error-11/#post-8881069)
 * I’m getting the same error – would love to get this fixed asap.
    -  This reply was modified 9 years, 2 months ago by [Millermore](https://wordpress.org/support/users/trentonm11/).
 *  [Joe Brodar](https://wordpress.org/support/users/jbrodar/)
 * (@jbrodar)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/php7-error-11/#post-8894866)
 * I posted this in another support thread as well:
 * I am not the developer, but I ran into the same compatibility issue that you 
   mentioned above, so I decided to look into the code and find out what is actually
   causing the error to be thrown.
 * What I found was that there is a foreach loop (starting line 675, ending line
   682) for which the developer used implicit braces, meaning that they chose not
   include the “{}” characters around the loop code block. Since the scanning plugin
   did not find those braces, it thinks that the “break” statement is outside of
   a loop block, which it actually isn’t. I have tested out a fix for this, that
   has resolved the compatibility error on my sites.
 * **The Fix**
    If you are comfortable with editing the PHP code of the plugin, 
   you just need to add explicit braces around the offending loop block.
 * So this:
 *     ```
       foreach ( array( 'media', 'posts', 'category', 'taxonomy' ) as $type )
       	if ( strpos( trim( $args['source'] ), $type . ':' ) === 0 ) {
       		$args['source'] = array(
       			'type' => $type,
       			'val'  => (string) trim( str_replace( array( $type . ':', ' ' ), '', $args['source'] ), ',' )
       		);
       		break;
       	}
       ```
   
 * becomes this:
 *     ```
       foreach ( array( 'media', 'posts', 'category', 'taxonomy' ) as $type )
       {
       	if ( strpos( trim( $args['source'] ), $type . ':' ) === 0 ) {
       		$args['source'] = array(
       			'type' => $type,
       			'val'  => (string) trim( str_replace( array( $type . ':', ' ' ), '', $args['source'] ), ',' )
       		);
       		break;
       	}
       }
       ```
   
 * The file that you need to update is “wp-content/plugins/shortcodes-ultimate/inc/
   core/tools.php”.
 *  [YoWangdu](https://wordpress.org/support/users/yowangdu/)
 * (@yowangdu)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/php7-error-11/#post-8899227)
 * Thanks Joe for sharing the solution. I hope Vladimir or MadFork will update the
   plugin. So when there is plugin updates, we don’t have to worry about the over
   writing code.
 * Thank you,
 * Lobsang
 *  [nuparks](https://wordpress.org/support/users/nuparks/)
 * (@nuparks)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/php7-error-11/#post-8991311)
 * This is great Joe! Thanks!
 *  [dzembak](https://wordpress.org/support/users/dzembak/)
 * (@dzembak)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/php7-error-11/#post-9430896)
 * Does not work for my site. If I copy paste code above, an error appears:
 * `Parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION)
   or const (T_CONST) in /home/***/wp-content/plugins/shortcodes-ultimate/inc/core/
   tools.php on line 687`
 * Please, update this plugin. With PHP 5.6 my site runs very slow…
    -  This reply was modified 8 years, 9 months ago by [dzembak](https://wordpress.org/support/users/dzembak/).

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

The topic ‘PHP7 Error’ is closed to new replies.

 * ![](https://ps.w.org/shortcodes-ultimate/assets/icon-256x256.gif?rev=2547563)
 * [Shortcodes Ultimate - Content Elements](https://wordpress.org/plugins/shortcodes-ultimate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcodes-ultimate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcodes-ultimate/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcodes-ultimate/reviews/)

 * 6 replies
 * 6 participants
 * Last reply from: [dzembak](https://wordpress.org/support/users/dzembak/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/php7-error-11/#post-9430896)
 * Status: not resolved