$i
and $j
are not within the visible scope of tabs()
:
… [W]ithin user-defined functions a local function scope is introduced. Any variable used inside a function is by default limited to the local function scope.
Pass them as parameters or make them global (the first being the preferred way):
Parameters
$i = $_POST['entry'];
$j = $_POST['j'];
function tabs($i, $j) {
if ($i < $j)
echo 'i is less than j';
else
echo 'false';
};
tabs($i, $j);
Global
$i = $_POST['entry'];
$j = $_POST['j'];
function tabs() {
global $i, $j;
if ($i < $j)
echo 'i is less than j';
else
echo 'false';
};
tabs();
EDIT
Alternatively, you can access the superglobal $_POST
array from within the tabs()
function directly, or $_GLOBALS['i']
and $_GLOBALS['j']
, respectively.