As for when I use which
let's say I had a function like this
<?php
function count_letters($string,$letter) {
if(strlen($string) < 1) {return FALSE;}
elseif(strlen($letter) > 1) {return FALSE;}
$i=0;
$temp = 0;
while(strpos($string,$letter,$temp) !== FALSE) {
$temp = strpos($string,$letter,$temp) + 1;
$i++;
} //end while
return $i;
} //end count_letters
First you'll notice that the while condition uses !== this is because strpos returns FALSE if it is not found but would return 0 if it is the first character, so I need to differentiate between not found and found in the first position.
Secondly notice that if the letter is not found I return 0 but if the parameters are wrong I return FALSE. So if I were checking if this function ran properly I would have to use === or !== to also check the type of the return value.