PHP中字符串的连接

时间:2017-01-10 15:19:01

标签: php string string-concatenation

我有一个文件夹路径,我需要与子文件夹连接,子文件夹存储在变量中,用于ex:

我有一条路径somepath\theme现在我想在文件夹中添加一个名为somepath\theme\themeone的主题,我将这个主题存储在变量中并尝试连接

$themename = 'themeone';
$path = 'somepath\theme\' . $themename;

我收到意外的文件结束错误。

1 个答案:

答案 0 :(得分:2)

查看语法高亮显示。你是最后一个斜线是逃避撇号导致你的字符串不终止。结果你留下了一个开放的字符串。你需要逃避反斜杠。

$themename = 'themeone';
$path = 'somepath\\theme\\' . $themename;
相关问题