我想连接以下两个变量$path1并$path2得到$path,然后$path与$filename得到连接$fullpath。任何帮助,将不胜感激。
$path1="images"
$path2= "\"
$path = $path1+$path2
$fullpath=$path + $filename
我想连接以下两个变量$path1并$path2得到$path,然后$path与$filename得到连接$fullpath。任何帮助,将不胜感激。
$path1="images"
$path2= "\"
$path = $path1+$path2
$fullpath=$path + $filename
$path1="images"
$path2= "\\"
$path = $path1.$path2
$fullpath=$path.$filename
请记住,您必须转义字符\(使用转义字符\)。.最后,使用运算符执行 PHP 中的字符串连接
您可以在 php 中使用连接运算符 ('.')。
$path1 = "images";
$path2 = "\";
$path = $path1.$path2;
$fullpath = $path.$filename;
PHP 使用.(dot) 来连接字符串,而不是+,所以试试吧。
手册参考: http: //php.net/manual/en/language.operators.string.php
您可以使用 dot(.) 在 php 中进行连接,例如
$path = $path1.$path2
$fullpath=$path.$filename