Well, as I'm an old PH[p]art that's not into OOP, can't say I'm sure, but likely a matter of operator precedence that set the entire expression to NULL prior to evaluating it?
And, technically speaking, that's not a parse error, but a logic/programming one, otherwise known as PBKAC ... but I'm very guilty of those 😉
One of the smart guys will get it if I'm wrong...
Here's one that's all too common, I suppose; culled from some post on here that I thought about responding to, but didn't:
<?php
$auth = false;
if(isset($_POST["login"])) {
$user = $_POST["username"];
$password = $_POST["password"];
$cookie = $_POST["cookie"];
}
ob_start();
include("./root.txt");
$root = ob_get_contents();
ob_end_clean();
$file = file ("$root/data/members.txt");
foreach ($file as $line) {
list($id, $userdata, $md5password)= explode ("|", $line);
if($user == $userdata and md5($password) == $md5password) {
$auth = true;
} else {
print("Incorrect username/password combination.");
}
if ($auth = true)
{
header("Set-Cookie: userid=$user; path=/");
if ($user == $userdata)
{
header("Set-Cookie: id=$id; path=/");
{
header("Set-Cookie: pass=$md5password; path=/");
header("Location: <a href="http://" target="_blank">http://</a>".$HTTP_SERVER_VARS
['HTTP_HOST']."/forums/index.php");
print("Thanks. You are now logged in as: ");
print("<b>{$user}</b> - <a href='../index.php'>Click ");
print(" here</a> to return to the forum index.");
}
}
}
}
?>
which yields ...
Parse error: parse error in /www/phptests/thistest.html on line 31
Of course, there's a couple other things I wouldn't do, either, I suppose....