>我正在尝试在包含路径中连接多个字符串,如下所示:
include dirname(dirname(dirname(dirname(__FILE__)))) . ''application'language'
. '"'"' . SystemConfiguration::$language . ''language.php';
但我得到这个结果:
C:''Bitnami''wampstack-5.5.29-1''apache2''htdocs''MyApp''application''language"''"italiano''language.php
但应该是:
C:''Bitnami''wampstack-5.5.29-1''apache2''htdocs''MyApp''application''language''italiano''language.php
知道吗?
Jut use
. '''' .
而不是
. '"'"' .
反斜杠用于转义,包括您需要添加双反斜杠 ('') 的转义,并且您正在添加单引号和双引号,这就是在您的路径中添加"''"的原因。
您可能希望考虑使用 set_include_path()
- 您可以使用如下所示:
define( 'DS', DIRECTORY_SEPARATOR );
set_include_path( $_SERVER['DOCUMENT_ROOT'] . DS .'application' . DS .'language' );
include "italiano'language.php";
/* or, more in keeping with the path */
include "italiano" . DS . "language.php";
您必须使用以下语法:
(...) ''application'language' . '''' (...)
查看有关单引号字符串的详细信息
使用两个反斜杠。这就是使用文字反斜杠的方式。
http://php.net/manual/en/language.types.string.php
include dirname(dirname(dirname(dirname(__FILE__)))) . '''application''language' . '"'"' .
SystemConfiguration::$language . ''language.php';
角色逃生:http://www.hackingwithphp.com/2/6/2/escape-sequences
include "C:''path''to''file.php";
请注意,PHP 也接受/
在所有系统(包括 Windows)上用作目录分隔符,因此始终使用斜杠不是问题。