您的位置:首页 > 编程语言 > PHP开发

[李景山php]每天laravel-20160910|Filesystem-1

2016-07-11 11:11 573 查看
namespace Illuminate\Filesystem;

use ErrorException;
use FilesystemIterator;
use Symfony\Component\Finder\Finder;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
// long time ago ,never see namespace so better, now I will use it more
class Filesystem
{
use Macroable;// this is a trait class like a real  class

/**
* Determine if a file or directory exists.
*
* @param  string  $path
* @return bool
*/
public function exists($path)
{
return file_exists($path);// a method wrap
}// Determine if a file or directory exists.

/**
* Get the contents of a file.
*
* @param  string  $path
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function get($path)
{
if ($this->isFile($path)) {// Determine is a file
return file_get_contents($path);//get file contents
}

throw new FileNotFoundException("File does not exist at path {$path}");
}// get file contents
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: