如何在函数调用中使用文本回显 php 变量?
使用thumbsup 脚本生成各种事物的评级。这是当前代码:
echo ThumbsUp::item($reviewid)->template('mini_thumbs2')->format('{UP} out of {TOTAL} people found this review helpful')
我尝试在 $reviewid
之前添加文本 review_
。无论我如何尝试,Dreamweaver 都将停止显示错误,但变量不会传递。我尝试的最后一件事是:
echo ThumbsUp::item('review_$reviewid')->template('mini_thumbs2')->format('{UP} out of {TOTAL} people found this review helpful')
Using the thumbsup script to generate ratings for various things. Here is the current code:
echo ThumbsUp::item($reviewid)->template('mini_thumbs2')->format('{UP} out of {TOTAL} people found this review helpful')
I'm trying to add the text review_
before $reviewid
. No matter what I try, Dreamweaver will stop showing errors, but the variable doesn't pass through. Last thing I tried is:
echo ThumbsUp::item('review_$reviewid')->template('mini_thumbs2')->format('{UP} out of {TOTAL} people found this review helpful')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您尝试过使用双引号吗?除非使用双引号,否则变量(这也是 Perl 的规则)不会插入到字符串中。
或者,您可以使用字符串连接来执行相同的操作:
Have you tried using double quotes? Variables (and this is the rule for Perl too) won't interpolate into strings unless you use double quotes.
Alternatively, you could use string concatenation to do the same thing:
我建议您使用大括号转义变量,因为这种方法允许您使用对象变量,例如:
I would recommend you escape variables with curly brackets, as this approach allows you to use object variables, example:
变量不会在“”内扩展,而仅在“”内部扩展。
Variables are not expanded within '', only within "".