Skip to content Skip to sidebar Skip to footer

How To Pass Php Variable Into Html Syntax Class Name?

How to pass php variable in html syntax, below code was wrong....
'> text

Solution 1:

Try this

<divclass="lid <?phpecho$row['class_name']; ?>">

Short tags only work by default after version PHP 5.4, and you have to enable shorthand tags for versions before that, in the php settings. <?=?> and <?php echo ?> are the same thing, with short tags enabled, but without them, may not be registered as PHP

Solution 2:

Based on the documentation:

echo also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. Prior to PHP 5.4.0, this short syntax only works with the short_open_tag configuration setting enabled.

To enable this syntax you can do one of the following

  • set short_open_tag = 1 in your php.ini file
  • add php_value short_open_tag 1 in your .htaccess file

If neither of these are available you will have to use a full php flag with an echo

<?phpecho$row['class_name']; ?>

Post a Comment for "How To Pass Php Variable Into Html Syntax Class Name?"