0
点赞
收藏
分享

微信扫一扫

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

玩物励志老乐 2023-03-02 阅读 44


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


举报

相关推荐

0 条评论