‘%s’ not in the ‘loop’ or ‘switch’ context

Description

break and continue are used to jump out of a loop, and proceed from the end of that loop. Since PHP 7.0, it is not possible to use them outside such a structure.

They can’t be used in a match.

Example

<?php

continue;

break;

?>

Literal Examples

  • ‘break’ not in the ‘loop’ or ‘switch’ context

  • ‘continue’ not in the ‘loop’ or ‘switch’ context

Solutions

  • Remove the break.

  • Remove the continue.

  • Move the break inside a switch block.

  • Move the continue inside a loop block: for, foreach, while, do..while.