For your first question,
your getnext()
function must be return some valid integer value then only you can compare it with integer 1.
for second,You should write
if($a == 1 && $b == 1){ echo 'both are 1';}else if($a == 1){ echo '$a is 1';}else if($b == 1){ echo '$b is 1';}else{ // both are not 1}
also see this links,logical operators or vs || (double pipe) in php