草庐IT

content_type

全部标签

PHP - zip 文件中子目录内文件的 file_get_contents()

我有一个.zip文件,里面有多个子目录和文件。如何使用file_get_contents()获取zip文件的子目录之一中的文件内容? 最佳答案 如果您安装了Zip扩展,它应该已经注册了zip://compressionwrapper.尝试以下操作:$result=file_get_contents('zip://path_to_my.zip#subDir/foo.txt'); 关于PHP-zip文件中子目录内文件的file_get_contents(),我们在StackOverflow上

php - file_put_contents(.../bootstrap/cache/services.json) : failed to open stream: No such file or directory

我在运行任何phpartisan命令时一直收到此错误。[ErrorException]file_put_contents(/Applications/MAMP/htdocs/code/bheng/md-bheng/bootstrap/cache/services.json):failedtoopenstream:Nosuchfileordirectory我该如何阻止它? 最佳答案 编辑-如果services.json文件不存在,运行phpartisanserve然后停止强制创建文件。请参阅:laravelservices.jsonn

PHP7 : Methods with a scalar type declaration refuse to type juggle NULL values, 即使在弱/强制模式下

截至PHP7.0,标量类型提示int、float、string和bool可以包含在方法签名中。默认情况下,这些类型声明以弱/强制模式(或“typejuggling”模式)运行。根据PHPmanual:PHPwillcoercevaluesofthewrongtypeintotheexpectedscalartypeifpossible.Forexample,afunctionthatisgivenanintegerforaparameterthatexpectsastringwillgetavariableoftypestring.但即使可以将NULL强制转换为整数0,具有int类型提

php - 在从源代码编译的 PHP 7.1 上安装 SPL_Types

我正在尝试在从源代码编译的PHP7.1.8中安装SPL_Types扩展。我尝试使用sudopeclinstallSPL_Types并从源代码编译扩展,但我得到以下输出:https://mega.nz/#!WE5WjajQ!QyVxMYWrsUiDF6Gq09psYBpR5Y336v26PusnlBNd8bg我知道发布链接并不酷,但我无法将空洞输出放在这里。 最佳答案 此扩展现已过时,无法使用PHP7.x构建。此库的最新版本released2012年,仅支持PHP5.4。native标量类型声明支持使此扩展几乎无用(可能除了SplEn

php - "Type error: Too few arguments to function App\Http\Controllers\UserController::attendance(), 0 passed and exactly 1 expected"

我的数据库中有两个表,分别是用户表和出勤表。我现在想做的是根据用户在与他们的个人资料相关联的出勤View中显示数据库中的出勤数据。这是我在userController中的考勤功能。publicfunctionattendance($id){$user=UserProfile::findOrFail($id);$this->authorize('modifyUser',$user);returnview('user.attendance',['user'=>$user]);}这是我到出勤View的路径。Route::get('/attendance/',['as'=>'user.atte

php - file_get_contents() PHP 的全局错误处理

我在使用file_get_contents时偶尔会遇到错误,它在我的脚本中使用得相当多。我知道我可以使用@file_get_contents单独抑制错误,并且可以使用设置全局错误消息//errorhandlerfunctionfunctioncustomError($errno){echo'OhNo!';}//seterrorhandlerset_error_handler("customError");但是我该如何专门为所有file_get_content的使用设置错误处理程序呢?谢谢 最佳答案 您可以在调用file_get_co

php - file_get_contents 或 fopen 用于读取几 MB 的 php ://input?

这似乎是一个重复的问题,但事实并非如此:我通过php:/input(1-500mb)收到了数兆字节的数据,我必须将这些数据保存在一个文件中。更性能明智(服务器负载,速度)使用:file_put_contents($filename,file_get_contents('php://input'))或$input=fopen("php://input","r");$temp=tmpfile();$realSize=stream_copy_to_stream($input,$temp);fclose($input);$target=fopen($filename,"w");fseek($t

php - PHP 的 file_get_contents 内存和数据效率高吗?

我正在制作一个推送通知服务器,它从外部(第三方)html页面收集特定数据,如果我知道我需要的信息在第一个内,例如5000个字符,如果我声明MAX_LENGTH,PHP实际上会使用更少的内存吗?还是整个页面都完全加载到内存中了?此外,是否下载了整个html页面,或者一旦达到限制,连接是否断开?(进而节省数据传输成本)$html=file_get_contents("http://.....",false,null,-1,5000);谢谢。 最佳答案 是的,它确实节省了内存和带宽......我还进行了速度测试(这与这个问题并不完全相关,

php - 安装时没有引号的 eav_entity_type

起源...我有一个带有设置脚本的模块(常见的mysql4-upgrade-0.1.0-0.1.1.php),添加一个属性来引用:$eav=newMage_Eav_Model_Entity_Setup('sales_setup');$eav->addAttribute('quote','my_attribute',array('type'=>'varchar'));如果我在空数据库上运行我的magento商店,设置脚本会运行,并且“错误的实体ID”错误会中断该过程。调用堆栈指向我的设置脚本。...寻找...如果我转到数据库,我会看到eav_entity_type表已填充但只有8种类型:报

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