I looked at the source code of thinkphp3.2 today and found that the connect method in Thinkphp/Library/Think/Storage.class.php is a bit confusing. The code is:
/** * 连接分布式文件系统 * @access public * @param string $type 文件类型 * @param array $options 配置数组 * @return void */ static public function connect($type='File',$options=array()) { $class = 'Think\Storage\Driver\'.ucwords($type); self::$handler = new $class($options); }
Why does the path in $class need "\\" instead of "\\"? The last "\\" is to convert "'" single quotes, which is understandable, but the first two "\\" are not That's very understandable, because in my memory it seems that it is possible to use "\" directly, and here, no error is reported when changing "\\" to "\". I think it may be for some better or safer considerations. , or for use in __autoload() later, but specifically why "\\" should be written, I hope any brother knows, let me know, thank you!
Simply put, it is more rigorous to use
\
to avoid problems that may arise when usingalone. In actual production, as long as there is no escaping problem, the specific writing is the same, but the premise is that you are very sure of your code. If you are not sure, writing
\
is a more reliable solution.