本文共 1099 字,大约阅读时间需要 3 分钟。
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 moreclass 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
转载于:https://blog.51cto.com/jingshanls/1825269