如何在 symfony2 中使用文件系统函数“存在"? [英] How to use file system function 'exists' in symfony2?

查看:27
本文介绍了如何在 symfony2 中使用文件系统函数“存在"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了 symfony2 API 文档这里

I checked symfony2 API docs here,

Symfony\Component\Filesystem\Filesystem 中很少有文件系统函数可用

Few File system functions are available in Symfony\Component\Filesystem\Filesystem

我使用了mkdir",它运行良好,但无法使用exists"功能

i used 'mkdir' and it worked fine but, unable to use 'exists' function

public Boolean 存在(string|array|Traversable $files)

public Boolean exists(string|array|Traversable $files)

它给出了错误

Fatal error: Call to undefined function Survey\BlogBundle\Controller\exists()

推荐答案

你确定不是

bool file_exists ( string $filename )

http://php.net/manual/de/function.file-存在.php

查看文档我发现有一个存在的功能.所以也许你错过了添加 use 语句

Looking at the docs I see that there is an exists function. So maybe you have missed to add a use statement

use Symfony\Component\Filesystem\Filesystem;

但是你仍然可以使用 file_exists

如何使用文件系统的详细信息http://symfony.com/doc/master/components/filesystem.html

Detailed information on how to use filesystem http://symfony.com/doc/master/components/filesystem.html

2.1 版的新功能:文件系统组件是 Symfony 2.1 的新功能.以前,Filesystem 类位于 HttpKernel组件.

New in version 2.1: The Filesystem Component is new to Symfony 2.1. Previously, the Filesystem class was located in the HttpKernel component.

这篇关于如何在 symfony2 中使用文件系统函数“存在"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆