dongshao1021 2016-07-23 19:06
浏览 89
已采纳

echo语句中的Echo Variable

I am trying to echo a php variable inside of a php echo statement.

I have a column in a MySql database called display_code which contains a value such as $num_rows_customers.

I am calling this from the DB as displayCode

$displayCode = $row ['display_code'];

And trying to echo like this:

 <?php    
           echo "<div class='col-md-3'>
           $displayCode
           </div>";

 ?>

However this is printing $num_rows_customers instead of a number

Is there a way to do this?

By the way, I already have this script on the page

<?php $result100=mysql_query("SELECT * FROM customers")or die('Error 27' . mysql_error());
$num_rows_customers = mysql_num_rows($result100);?>
  • 写回答

1条回答 默认 最新

  • douchou8935 2016-07-23 19:10
    关注

    About Variable variables read here

    $displayCode = 'num_rows_customers';
    $num_rows_customers = 10;  
               echo "<div class='col-md-3'>
               {$$displayCode}
               </div>";
    

    demo

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致