Reputation: 11
Whenever I see output it displays $iV is less than 10. but i want $iV
to display the number instead of the name of variable what am i doing wrong here?
$iV = 7;
if($iV > 10)
{
$r = '$iV is greater than 10';
}
else
{
$r = '$iV is less than 10';
}
echo "<p>$r</p>"
Upvotes: 1
Views: 32
Reputation:
Use double quotes ("
) instead of single quotes ('
). Variables are not escaped in single quoted strings.
Note: Unlike the double-quoted and heredoc syntaxes, variables and escape sequences for special characters will not be expanded when they occur in single quoted strings.
Working code:
$iV = 7;
if($iV > 10)
{
$r = "$iV is greater than 10";
}
else
{
$r = "$iV is less than 10";
}
echo "<p>$r</p>"
Upvotes: 1