1、FILE
在app.php输出如下
echo __FILE__;
结果为: D:\www\laravel5.1\bootstrap\app.php
2、DIR
假设1中代码在bootstrap目录
echo __DIR__; // 等同于 dirname(__FILE__)
结果为: D:\www\laravel5.1\bootstrap
3、DIRECTORY_SEPARATOR
目录分隔符 这个PHP定义的常量
define (‘DIRECTORY_SEPARATOR’, “/”);
使用示例:
return $this->basePath.DIRECTORY_SEPARATOR.’app’;
4、::class
这个是PHP新增的静态属性,主要是获取类名字符串的,在laravel框架中常见到这种用法,如
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
5:PHP_VERSION
php版本常量