• Hello,

    My site runs on Siteground servers. Siteground’s PHP compatibility tester in their SG Optimizer plugin showed this error for PHP 7.1 compatibility:

    FILE: /home/pennbroo/public_html/wp-content/plugins/easy-fancybox/inc/class-easyfancybox.php
    ------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------
     40 | ERROR | Using 'break' outside of a loop or switch structure is invalid and will throw a fatal error since PHP 7.0
    ------------------------------------------------------------------------------------------------------------------------

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hi, thanks for reporting ??

    The plugin has been tested on PHP 7 and the break there on line 40 is actually inside a foreach loop. Apparently the SiteGround Optimizer plugin does not recognize it as a loop and shows this error.

    If you wish, you can test the following change (using the WordPress plugin Editor) to inc/class-easyfancybox.php to see if the SG?message disappears.

    Find around line 40 the following code part:

    
    foreach ( self::$options['Global']['options']['Enable']['options'] as $value )
    	if ( isset($value['id']) && '1' == get_option($value['id'],$value['default']) ) {
    		self::$add_scripts = true;
    		break;
    	}
    

    And change it to

    
    foreach ( self::$options['Global']['options']['Enable']['options'] as $value ) 
    {
    	if ( isset($value['id']) && '1' == get_option($value['id'],$value['default']) ) {
    		self::$add_scripts = true;
    		break;
    	}
    }
    

    by placing an opening { at the and of line 37 and a closing } on a new line after the } on line 41.

    Please let me know if that indeed fixes the SG error or not ??

Viewing 1 replies (of 1 total)
  • The topic ‘Error showing in PHP 7.1’ is closed to new replies.