Ghugu
Ghugu

Reputation: 489

Not able to show the title in PHP inside loop

I am not able to find the error why my title is not displaying. This is my code:

echo '<br /><b style="display:block";>'.$name .'</b>';
echo '<i style="color:red";>'.$class.'';

Can you please help me?

Upvotes: 0

Views: 63

Answers (2)

Ahmed Numaan
Ahmed Numaan

Reputation: 1062

It is not recommended to echo HTML tags inside PHP script. Your code should have been written as follows. I see that closing tag </i> is missing as well. I hope this might solve your problem.

    <br />
    <b style="display:block;">
      <?php echo $name;?>
    </b>
    <i style="color:red;">
      <?php echo $class;?>
    </i>

Upvotes: 1

A l w a y s S u n n y
A l w a y s S u n n y

Reputation: 38502

Remove the unnecessary last single quotes '', Also put your semicolon ; inside the double quotes "

<?php
$title = 'this is title value'; //example title
$des = 'this is description';  // example description 
echo '<br /><b style="font-size:1.5em;">'.$title.'</b>'; 
echo '<i style="font-size:18px;">'.$des;
?>

DEMO: https://eval.in/1044486

Upvotes: 2

Related Questions