Title: PHP 7 Compatibility
Last modified: August 24, 2016

---

# PHP 7 Compatibility

 *  Resolved [BrentNewland](https://wordpress.org/support/users/brentnewland/)
 * (@brentnewland)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/php-7-compatibility/)
 * `[06-Apr-2015 07:10:16 UTC] PHP Fatal error: ‘continue’ not in the ‘loop’ or ‘
   switch’ context in C:\Server\www\beta\wp-content\plugins\amr-shortcode-any-widget\
   amr-shortcode-any-widget.php on line 210
 * I believe the extension needs some minor changes before becoming PHP 7 compatible.
 * [https://wordpress.org/plugins/amr-shortcode-any-widget/](https://wordpress.org/plugins/amr-shortcode-any-widget/)

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

 *  Plugin Author [anmari](https://wordpress.org/support/users/anmari/)
 * (@anmari)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/php-7-compatibility/#post-5982894)
 * Hi Brent, thanks for the heads up. Always good to future proof code. and you 
   made me check what else is changing in php 7!
 * That particular piece of code was lifted straight out of wp’s sidebar code in
   wp-includes/widgets.php (currently round about line 1188 of the WordPress 4.2-
   beta4-32059 ),so it looks like it’s more than just this plugin that will be needing
   some changes for php 7.0 😉
 * With some quick googling I couldn’t find out if there was a reasonable stable
   version to run on a wamp install – any advice? since you must be in the ‘know’?
 *  Thread Starter [BrentNewland](https://wordpress.org/support/users/brentnewland/)
 * (@brentnewland)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/php-7-compatibility/#post-5982897)
 * I had to ask online to find the PHP 7 nightly snapshots are here [http://windows.php.net/snapshots/](http://windows.php.net/snapshots/)
   at the bottom under “Master”. I converted two WordPress installations to it and
   it’s much faster. If you’re using PHP in FastCGI mode, I’d recommend the x64 
   Non-Thread-Safe build.
 * On my server, using nginx (for now), it’s pretty easy to configure PHP per domain.
   I have PHP5 running as one Windows service (for our server’s Owncloud), and another
   PHP7 service for our WordPress sites. Here’s a guide I wrote on installing PHP
   as a Windows service: [http://forum.nginx.org/read.php?2,236376,236376](http://forum.nginx.org/read.php?2,236376,236376)
 * Though our current WinSW FastCGI configuration code looks like this:
 *     ```
       <service>
         <id>PHP7</id>
         <name>PHP7</name>
         <description>This service handles the primary PHP7 FastCGI server.</description>
         <executable>C:\server\php7\php-cgi.exe</executable>
         <arguments>-b 9127 -c c:\server\php7\php.ini</arguments>
         <env name="InstanceMaxRequests" value="0" />
         <env name="pm.max_requests" value="0" />
         <env name="PHP_FCGI_MAX_REQUESTS" value="0" />
         <stopexecutable>C:\SERVER\php7\php-stop.cmd</stopexecutable>
         <logpath>C:\server\logs\php7</logpath>
         <log mode="roll-by-size">
           <sizeThreshold>256</sizeThreshold>
           <keepFiles>128</keepFiles>
         </log>
       </service>
       ```
   
 * And php-stop.cmd consists of just “taskkill /f /IM php-cgi.exe”
 * Anyways, back to the topic, looking at the WordPress code, it appears the problem
   is that the code used in WordPress’s widgets.php is in a foreach loop. The immediate
   preceding code from widgets.php:
 * `foreach ( (array) $sidebars_widgets[$index] as $id ) {`
 * However, your script’s code does not have a foreach loop, therefore “continue”
   is not correct for that location. Continue is for use in loops only. [http://php.net/manual/en/control-structures.continue.php](http://php.net/manual/en/control-structures.continue.php)
   I’m pretty sure, right now, that if statement does nothing.
 * I think change:
 *     ```
       if ( !isset($wp_registered_widgets[$widget_id]) ) continue;
   
       		$params = array_merge(
       			array(
       				array_merge( $sidebar,
       					array('widget_id' => $widget_id,
       						'widget_name' => $wp_registered_widgets[$widget_id]['name']) ) ),
       						(array) $wp_registered_widgets[$widget_id]['params']
       		);
       ```
   
 * to
 *     ```
       if ( !isset($wp_registered_widgets[$widget_id]) ) {
   
       		$params = array_merge(
       			array(
       				array_merge( $sidebar,
       					array('widget_id' => $widget_id,
       						'widget_name' => $wp_registered_widgets[$widget_id]['name']) ) ),
       						(array) $wp_registered_widgets[$widget_id]['params']
       		);
       	}
       ```
   
 *  Plugin Author [anmari](https://wordpress.org/support/users/anmari/)
 * (@anmari)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/php-7-compatibility/#post-5982909)
 * Hi re code : actually if the id is not in the set of registered widgets we just
   want to exit, not do anything, which I guess I was thinking the continue would
   do as it does in the loop – skip to the next bit of code. BUT Actually the code
   should never have executed as the situation of not a valid id gets trapped before
   that!
 * any way – thanks for info
 *  [justinsamuel](https://wordpress.org/support/users/justinsamuel/)
 * (@justinsamuel)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/php-7-compatibility/#post-5983043)
 * > With some quick googling I couldn’t find out if there was a reasonable stable
   > version to run on a wamp install – any advice?
 * Just in case you haven’t found a good way to test PHP 7 yet, it’s now available
   by default on servers configured by [ServerPilot](https://serverpilot.io/). So,
   you can use a $5/month DigitalOcean server, connect it to ServerPilot, use ServerPilot’s
   one-click WordPress install, and test your plugin on PHP 7. DigitalOcean actually
   bills hourly and ServerPilot has a free plan, so it won’t cost much to test that
   way.
 *  [jfbrouillette](https://wordpress.org/support/users/jfbrouillette/)
 * (@jfbrouillette)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/php-7-compatibility/#post-5983062)
 * [@anmari](https://wordpress.org/support/users/anmari/): Any update about this
   issue? I’m having the same problem with this plugin and can’t find how to solve
   this..
 *  Plugin Author [anmari](https://wordpress.org/support/users/anmari/)
 * (@anmari)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/php-7-compatibility/#post-5983063)
 * jfb
    please upgrade to 2.9.
 * The current version does not use ‘continue’ anywhere, so it will not be possible
   to have this same problem
    “PHP Fatal error: ‘continue’ not in the ‘loop’ or ‘
   switch’ context”
 * if your problem is actually something else to do with this plugin and not the
   widgets you are using, please post a new topic

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

The topic ‘PHP 7 Compatibility’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/amr-shortcode-any-widget_dde8e5.svg)
 * [amr shortcode any widget](https://wordpress.org/plugins/amr-shortcode-any-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amr-shortcode-any-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amr-shortcode-any-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/amr-shortcode-any-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amr-shortcode-any-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amr-shortcode-any-widget/reviews/)

## Tags

 * [PHP7](https://wordpress.org/support/topic-tag/php7/)

 * 6 replies
 * 4 participants
 * Last reply from: [anmari](https://wordpress.org/support/users/anmari/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/php-7-compatibility/#post-5983063)
 * Status: resolved