Why if/else vs. or/exit in PHP?

Viewed 1513

Seeing the exit() PHP documentation got me thinking:

$filename = '/path/to/data-file';
$file = fopen($filename, 'r')
or exit("unable to open file ($filename)");

Couple questions:

  1. What are common use cases besides opening files for using exit()?
  2. Since not every function everyone ever writes ends in exit(), how do you know to use it in some contexts vs. others?
  3. Are if/else and or/exit interchangeable?
4 Answers
Related