This PHP IF statement always results in ‘false’ and I can’t figure out why. Any help is greatly appreciated.
Where $i is passed in as 0 and $j is passed in as 4 (these numbers were verified in the POST)
$i = $_POST['entry'];
$j = $_POST['j'];
function tabs() {
if ($i < $j)
echo 'i is less than j';
else
echo 'false';
};
$iand$jare not within the visible scope oftabs():Pass them as parameters or make them global (the first being the preferred way):
Parameters
Global
EDIT
Alternatively, you can access the superglobal
$_POSTarray from within thetabs()function directly, or$_GLOBALS['i']and$_GLOBALS['j'], respectively.