草庐IT

data-files

全部标签

php,realpath 与 realpath + file_exists 用法

出于性能原因,我们应该只使用realpath()而不是realpath()+file_exists()在检查文件或目录是否存在时??案例A::if(realpath(__DIR__."/../file.php")===false)案例B::if(file_exists(realpath(__DIR__."/../file.php"))===false)我认为CASEA完成了工作,而CASEB完成了两次工作。 最佳答案 不仅情况B是多余的(因为根据docs,如果路径无法解析或文件不存在,则realpath返回false),如果文件不存

php - 性能 : file_get_contents(), 相对和绝对 URL

如果我在file_get_contents()中使用相对路径作为参数,是否有任何性能优势?file_get_contents("../../mypage.php");v/sfile_get_contents("http://.../mypage.php");内部如何处理file_get_contents()? 最佳答案 使用本地文件与使用远程文件肯定会有明显的性能差异-即使“远程”文件位于您的本地服务器上。当您使用本地/相关文件时,例如file_get_contents("../../mypage.php");,它会直接在服务器上加

php - 如何用PHP调用UploadHandler.php - blueimp jQuery File Upload

有谁知道如何使用PHP上传图片并调用UploadHandler.php?我不确定需要传递什么信息以及以什么格式传递。这是我目前所拥有的:$prop="test";session_id($prop);@session_start();$url='http://christinewilson.ca/wp-content/uploads/2013/02/port_rhdefence.png';$file_name[]=file_get_contents($url);error_reporting(E_ALL|E_STRICT);require('UploadHandler.php');$up

php - 使用 PHP AWS SDK 在 file_put_contents 上设置 ACL

require'vendor/autoload.php';useAws\S3\S3Client;$client=S3Client::factory(array('key'=>'MY_KEY','secret'=>'MY_SECRET'));//Registerthestreamwrapperfromaclientobject$client->registerStreamWrapper();$data=$_POST["image_data"];list($type,$data)=explode(';',$data);list(,$data)=explode(',',$data);$dat

php - Magento : Fatal error: Class 'Mage_Giftcards_Helper_Data' not found in . ..../app/Mage.php 第 546 行

我安装了一个模块扩展,它在管理员中抛出一个fatalerror“fatalerror:类‘Mage_Giftcards_Helper_Data’在..../app/Mage.php中找不到,第546行”。我已提交此链接https://stackoverflow.com/a/9191286/2919940还有这个链接https://magento.stackexchange.com/a/7133/3693但是我有Webtex_Giftcards_Helper在我的config.xml中,我有这个类classWebtex_Giftcards_Helper_DataextendsMage_C

PHP -l : suppress output on valid files

当使用php-lmyFile.php命令(PHP5.5.30)时,如果文件有语法错误,我会收到正确的警告和堆栈跟踪等。但是,如果文件没有语法警告,我会收到消息NosyntaxerrorsdetectedinmyFile.php有没有办法让命令在语法有效时没有输出?我只关心文件是否具有无效语法-我不需要说明它有效的消息。 最佳答案 “无语法错误...”消息在stdout上发送,而语法错误在stderr上发送。如果您不需要它们,您可以将它们重定向到类似/dev/null的地方。php-lfile.php1>/dev/null如果有错误则

php - file_get_contents false 当 url 有空格时(编码一切都不起作用)

所以,问题出在这一行$imageString=file_get_contents($image_url);具有空格字符的url不起作用。但是如果我让$imageString=file_get_contents(urlencode($image_url));没有任何效果。我一直在变量中收到false。ulr是这样的:https://s3-eu-central-1.amazonaws.com/images/12/Screenshotfrom2016-04-281815:54:20.png 最佳答案 使用这个函数functionescap

php - Symfony/Doctrine : fetching data as object

在Symfony中,我使用Doctrine_Query来查询数据库$q=Doctrine_Query::create()->from('Useru')->where('u.username=?',$username)->andWhere('u.password=?',$password);$user=$q->fetchArray();问题是结果存储在一个数组中。有什么方法可以让它获取对象而不是数组?此外,还有其他方法可以在Symfony中查询数据库,还是必须使用Doctrine的函数? 最佳答案 你可以使用$q->fetchOne(

php - 从 cgridview 中的按钮访问 $data 变量

有什么方法可以从CButtonColumn访问位于$data变量中的模型?以下代码无效。array('class'=>'CButtonColumn','template'=>'{test}','buttons'=>array('test'=>array('label'=>'Select','click'=>'js:function(){alert($data->_id);returnfalse;}',),),), 最佳答案 可以从jquery访问可见属性:'click'=>'js:function(){alert("firstele

PHP file_get_contents() 不工作

谁能解释为什么下面的代码会返回警告:我收到警告:Warning:file_get_contents(http://google.com):failedtoopenstream:Nosuchfileordirectoryonline2参见codepad 最佳答案 作为替代方案,您可以使用cURL,例如:$url="http://www.google.com";$ch=curl_init();curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_RETURNTRANSFER,