Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.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-在=';xx和x27;撇号';s_Php_Include_Apostrophe_Relative Url - Fatal编程技术网

PHP-在=';xx和x27;撇号';s

PHP-在=';xx和x27;撇号';s,php,include,apostrophe,relative-url,Php,Include,Apostrophe,Relative Url,我试图在$thumb\u目录和$orig\u目录中的“/images”之前的代码中插入一个相对URL,但是我不确定如何在“撇号”中这样做。此外,这是一个WordPress网站,因此如果有人知道如何在“/images”中调用函数,例如:“/images”,请让我知道(我知道我刚才键入的语法不正确) 假设相对路径在变量$rel\u path中, 使用双引号: $thumb_directory = "$rel_path/images"; $orig_directory = "$rel_path/ima

我试图在$thumb\u目录和$orig\u目录中的“/images”之前的代码中插入一个相对URL,但是我不确定如何在“撇号”中这样做。此外,这是一个WordPress网站,因此如果有人知道如何在“/images”中调用函数,例如:“/images”,请让我知道(我知道我刚才键入的语法不正确)


假设相对路径在变量
$rel\u path
中, 使用双引号:

$thumb_directory = "$rel_path/images";
$orig_directory = "$rel_path/images";
使用双引号时,变量(以
$
开头)将替换为其值,但单引号中不会出现这种情况

或使用字符串连接:

$thumb_directory = $rel_path . '/images';
$orig_directory = $rel_path . '/images';
编辑

如果您的相对路径来自
bloginfo('template_directory')
,只需在使用
$rel_path
之前添加以下行即可(因此在上述行之前):

这将设置具有所需路径的变量。
确保所有这些行都在PHP处理标记
中,并且不要忘记分号
位于分配行末尾;-)

非常感谢你!我正在开发这个作为WordPress主题的一部分,我想使用WordPress函数。你知道我如何用bloginfo('template_directory')替换$rel_path吗?
$thumb_directory = $rel_path . '/images';
$orig_directory = $rel_path . '/images';
$rel_path = bloginfo('template_directory');