Why is this php function not working? It does work when not using $element.
With $element it always returns test.
function setVar($element)
{
if(isset($_POST['$element'])){
$varname = $_POST['$element'];
}
else {
$varname = 'test';
}
return $varname;
}
$var = setVar('element_6');
You probably mean:
without the quotes? Single-quoted content never gets replaced.