Please check the code below:
<?php
$d=2;
echo "the sum of the number is"."<sub>($d+1)</sub>";
?>
Its giving as output:
the sum of the number is <sub>(2+1)</sub>
Ideally I need the output to be "the sum of the number is <sub>3</sub>".
It works fine when we don’t use the HTML tags <sub>…
How can I fix this?
try writing it as
the quotes give it a string representation and thus not allowing you to perform addition.