草庐IT

file_include

全部标签

php - 使用 include()、include_once() 和 require() 构造的实际场景

在include、include_once、require和require_once中,我总是只使用require_once。许多第三方框架也只使用require_once。谁能描述一个必须使用另一个结构的真实场景? 最佳答案 恕我直言,没有适合include和include_once的真实场景,原因有二:您不太可能打算包含一个文件,同时您并不真正关心它是否被包含(例如,如果文件不存在并且执行继续)。即使是这种情况,include也会发出警告,这是一种糟糕的风格(零警告代码是值得努力的好事)。大多数情况下,您可以使用is_file之

php - "./file"和 "file"相对路径有什么区别

我总是看到开发人员使用这两种类型的相对路径来包含外部文件。问题是,“require"./lib/helpers.php"和require"lib/helpers.php"据我所知,两者都指向同一个文件。但是,就复杂性而言,一个是否优于另一个?问候 最佳答案 ./lib/...将包含请求锚定在脚本的当前工作目录中。PHP将在那里寻找所需的文件,而不会在其他地方寻找。如果不存在,则不执行包含并继续执行。lib/...允许PHP扫描其包含路径,例如如果你有include_path=.:/var/lib/php:/foo/bar/baz然后

php - file_get_contents 同步或异步

今天遇到一种情况。我正在使用file_get_contents为用户从文件中获取token。$data=file_get_contents("http://example.com/aaa.php?user=tester&akey=abcdef1234");$dec=json_decode($data,true);$tokenid=$dec['message']['result']['tokenid'];使用token我将调用另一个文件来获取详细信息;$data=file_get_contents("http://example.com/bbb.php?user=tester&token

php - 当我添加 'files' => true 时,Laravel 表单不返回输入

我有一个看起来像这样的表格:{{Form::open(array('route'=>'notebook.store','files'=>true))}}{{Form::text('title',null,['class'=>'form-control','placeholder'=>'Title',])}}{{Form::text('description',null,['class'=>'form-control','placeholder'=>'Desc',])}}{{Form::file('path')}}{{Form::submit('Save',['class'=>'btnb

php - 未捕获的异常 'ImagickException',消息为 'Unable to read the file'

我正在运行带有imagick模块3.1.0RC2的PHP5.4.30。phpinfo()确实将模块显示为已加载,而phpinfo()将PDF显示为受支持的格式。运行时:$image=newImagick();$image->readImage('./test.pdf');我收到:fatalerror:未捕获的异常“ImagickException”和消息“无法读取文件:./test.pdf”当我将图像类型更改为JPEG并读取'./test.jpg'时,未返回任何错误。已检查权限并测试了不同的PDF。我已经插入了图像的绝对路径,但仍然抛出异常。此示例的图像与脚本放在同一目录中。我错过了什

php - 如何修复错误 "Fatal error: Uncaught --> Smarty: unable to write file"?

我使用digitalocean将Prestashop从本地主机迁移到网站域,但是当我打开该网站时出现此错误Fatalerror:Uncaught-->Smarty:unabletowritefile/var/www/html/prestashop/cache/smarty/compile/a4/36/f1/wrt549a35e49b3b44_77591243我尝试将smarty文件夹的权限更改为755,但没有成功。我不知道如何修复它。 最佳答案 你的问题肯定是关于权限的。这取决于Apache和PHP的设置方式。首先,检查谁拥有这些文

PHP file_get_contents() : content truncated from 2147483648 to 2147483647 bytes

当我要创建2GB文件的zip文件时,如何找出问题。错误file_get_contents():contenttruncatedfrom2147483648to2147483647bytesFatalerror:Outofmemory(allocated2151677952)(triedtoallocate18446744071562067968bytes)in我正在使用专用服务器并且已经设置了memory_limit,max_execution_time,max_upload_filesize,max_post_size。但这对我不起作用。请检查我的代码并让我知道我做错了什么-创建新的

php - 无法设置 PHP include_path

我已经在var/www/html中上传了我所有的文件,在我的一个php文件中我有这一行:require_once('libraries/stripe/init.php');我的文件夹结构如下:www-html/-libraries->Stripe->init.php-register.php我不断收到此错误消息:Warning:require_once(libraries/Stripe/init.php):failedtoopenstream:Nosuchfileordirectoryin/var/www/html/register.phponline116Fatalerror:req

php - Laravel 5 Elixir : How to mix copy multiple files

如何使用Elixir混合复制多个文件?这不起作用:mix.copy([['node_modules/vue/dist/vue.js','resources/assets/js/vendor/vue.js'],['node_modules/vue-resource/dist/vue-resource.js','resources/assets/js/vendor/vue-resource.js']]);任何其他建议,除了:mix.copy('node_modules/vue/dist/vue.js','resources/assets/js/vendor/vue.js');mix.cop

PHP-file_get_contents() : Filename cannot be empty

有人可以帮我处理这个错误吗?我不知道用什么方法或方法来摆脱这个错误。我是php的新手并开始学习它。有人可以给我想法吗?这里是错误:这是我的PHP代码。"enctype="multipart/form-data">Title"/>Date"/>Content"alt="yourimage"style="width:200px;height:140px;"/>functionreadURL(input){if(input.files&&input.files[0]){varreader=newFileReader();reader.onload=function(e){$('#blah')