如何将PHP变量传递给html语法类名? [英] How to pass php variable into html syntax class name?

查看:95
本文介绍了如何将PHP变量传递给html语法类名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在html语法中传递php变量,

低于代码错误....

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

<div class="lid <?=$row["class_name"]?>">
     text
</div>


推荐答案

基于文档

Based on the documentation:


echo还有一个快捷方式的语法,您可以立即使用等号跟随开始标记。在PHP 5.4.0之前,这个简短的语法只适用于启用short_open_tag配置设置。

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


  • 在您的php.ini文件中设置 short_open_tag = 1

  • 在您的.htaccess文件中添加 php_value short_open_tag 1
  • set short_open_tag = 1 in your php.ini file
  • add php_value short_open_tag 1 in your .htaccess file

如果这两个都不可用,您必须使用完整的php标志和echo

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

<?php echo $row['class_name']; ?>

这篇关于如何将PHP变量传递给html语法类名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆