PHP-串联两个变量 [英] PHP - Concatenating two variables

查看:112
本文介绍了PHP-串联两个变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是以下内容的新手。如果我在包含以下变量的页面上包含外部文件:

I'm a newbie stumped on the following. If I'm including an external file on a page that contains the following variable:

$blurb_78 = "Lorem ipsum dolor.";

如何在本地页面上回显$ blurb_78?
(其中 78 部分是生成的商品ID,设置为标记为 $ id 的变量)

How can I echo $blurb_78 on the local page? (where the 78 part is a generated article ID set to a variable labeled, $id)

以下操作无效:

echo $blurb_.$id;

非常感谢您的帮助。

推荐答案

我认为您的意思是变量变量名称,如变量变量页面在PHP网站上。在您的情况下,这应该可以正常工作:

I think you mean a variable variable name like it is mentioned at the Variable variables page on the PHP site. In your case this should work fine:

echo ${'blurb_'.$id}; 

但是我非常怀疑您对此的处理方式。

But I highly doubt your approach on this one.

这篇关于PHP-串联两个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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