dongtang8678 2011-02-22 21:16
浏览 30
已采纳

如何在字符串中计算常量? [重复]

Possible Duplicate:
Include constant in string without concatenating

How can I get a constant to be evaluated in a string like variables are?

$foo = "like";
define('BAR', 'fish');

// None of these give me 'I like to eat fish on Tuesday.'
echo "I $foo to eat BAR on Tuesday.";
echo "I $foo to eat {BAR} on Tuesday.";
echo 'I $foo to eat BAR on Tuesday.';

// This works but is undesirable
echo 'I $foo to eat '.BAR.' on Tuesday.';
  • 写回答

3条回答 默认 最新

  • dqydp44800 2011-02-22 21:31
    关注

    As far as I know that isn't possibile. Check this answer here at SO, it contains useful workarounds if concatenation is so undesirable too you! Include constant in string without concatenating

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发