i want to know how i can stop a loop from looping once an error has been found

for example i have this

while ($this > $that){
if($this == $that) {
echo 'stop this';
}
}