php - Correct use of equals syntax -
could please help me next code
if ($scope = '9001') $docref = $rs["9001ref"]; elseif ($scope = '14001') $docref = $rs["14001ref"]; elseif ($scope = '18001') $docref = $rs["18001ref"]; elseif ($scope = '9001,14001') $docref = $rs["914001ref"]; elseif ($scope = '9001,18001') $docref = $rs["918001ref"]; elseif ($scope = '14001,18001') $docref = $rs["1418001ref"]; elseif ($scope = '9001,14001,18001') $docref = $rs["91418001ref"];
i unsure if should using = or ==
and unsure if should using ' ' or " "
could please allow me know , provide brief explanation know going forward, give thanks you.
in comparing single =
means assigning value variable. e.g. $scope = '14001'
assign 14001
$scope
. compare something, utilize ==
(just if values same) or ===
(if values , types match). using '
versus "
code style matter. if using variables in string, "
parse string check if there variable inside, while '
ignore variable within string. e.g.:
$scope = '123'; echo "my scope {$scope}"; // echo "my scope 123"; echo 'my scope {$scope}'; // echo "my scope {$scope}";
also can utilize variable starts $
in "
wrapped string:
echo "variable {$variable}"; echo "string {$row['somekey']}"; echo "object {$this->variable}"; echo "object method returns value {$this->getvalue()}";
php comparison
No comments:
Post a Comment