I have these code:
<?php
$i=0;
while (true):
echo "test";
$i<4 ? $i++ : break;
endwhile;
?>
error message:
Parse error: syntax error, unexpected T_BREAK in C:\xampp\htdocs\data\index.php on line 5
there is a syntax error with the if condition, I can really make out what. can anybody help. thanks a lot.
The ternary operator is used for assignment or to return a value. You cannot place
breakin theelse (:)case of a ternary operation.It cannot be used for a regular
elsecase containing a language construct as you’re doing withbreak. Instead use a regularif()