Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP变量串联_Php_String Concatenation - Fatal编程技术网

PHP变量串联

PHP变量串联,php,string-concatenation,Php,String Concatenation,我试图将硬编码的变量值更改为动态,但似乎无法获得正确的串联 硬编码值为 $token = "../wp-content/themes/mytheme/styles/test/sidebar"; 我正试图用…来代替它 $token = ".get_bloginfo('template_directory')."styles/test/sidebar"; 但它的工作原理与我硬编码值时不同 我错过了什么 下面是代码的其余部分(imagegif函数永远不会使用动态生成的变量激发 $color = i

我试图将硬编码的变量值更改为动态,但似乎无法获得正确的串联

硬编码值为

$token = "../wp-content/themes/mytheme/styles/test/sidebar";
我正试图用…来代替它

$token = ".get_bloginfo('template_directory')."styles/test/sidebar";
但它的工作原理与我硬编码值时不同

我错过了什么

下面是代码的其余部分(imagegif函数永远不会使用动态生成的变量激发

$color = imagecolorallocate($img, $info["red"], $info["green"], $info["blue"]);
    for ($i = $startPixel-1; $i < $endPixel; $i++)
    {
        imagesetpixel($img, $i, 0, $color);
    }

    imagegif($img, $token.'.gif');
}
$color=imagecolorallocate($img、$info[“红色”]、$info[“绿色”]、$info[“蓝色”]);
对于($i=$startPixel-1;$i<$endPixel;$i++)
{
imagesetpixel($img,$i,0,$color);
}
imagegif($img,$token..gif');
}
是串联运算符,因此您不希望在引号中包含get_bloginfo()函数。这假定该函数返回以
/
结尾的字符串

$token = get_bloginfo('template_directory')."styles/test/sidebar";
这就是您的意思吗?您将函数作为字符串而不是函数。

从您的代码:

$token = ".get_bloginfo('template_directory')."styles/test/sidebar";
这行开头有一个错误的引号和句号。您可能想执行以下操作:

$token = get_bloginfo('template_directory') . "styles/test/sidebar";

函数调用不能在字符串内,并且连接运算符(
)必须在字符串外。

只有字符串应该用引号括起来

$token = get_bloginfo('template_directory') . "styles/test/sidebar";

你的演讲有点不对劲

尝试:
$token=get_bloginfo('template_directory')。'styles/test/sidebar';

“你的连接有点不对劲。”…这不是问题吗?也许我是说他的连接方式有点奇怪。但我想这是个问题;-)谢谢Fosco,我错过了。还必须在“样式”前面加上“/”。
$token = get_bloginfo('template_directory') . "styles/test/sidebar";