草庐IT

get_object_list

全部标签

php - fatal error : Using $this when not in object context - OOPHP

我只是想通过构造函数设置post_id并通过另一个函数获取该id。但它正在返回:fatalerror:不在对象上下文中时使用$this但不知道为什么会这样正在发生。我以前做过很多次,但现在出了问题。代码如下classPostData{privatestatic$instance=null;public$post_id=0;publicfunction__construct($post_id=0){if((int)$post_id>0){$this->setId($post_id);}}privatefunctionsetId($post_id){return$this->post_id

php - 如何修复 "Recoverable fatal error: Object of class Closure could not be converted to string in..."

当我执行这段代码时出现这个错误。我不知道该怎么办。请帮忙ResultadosparalabúsquedaNúmeroderesultadostotal: 最佳答案 你的问题出在这里$numRows=(function()use($total){if($total你必须在括号之间包装函数,如果你想传递参数,你应该使用use() 关于php-如何修复"Recoverablefatalerror:ObjectofclassClosurecouldnotbeconvertedtostringin

php - HMAC - 在 Objective-C 中实现 PHP 算法

我必须在我的iPhone应用程序中实现HMACMD5。该算法的PHP版本(用于验证的服务器端实现)在这里,我不能修改它(它是一个API)functionhmac($key,$data){$b=64;//bytelengthformd5if(strlen($key)>$b){$key=pack("H*",md5($key));}$key=str_pad($key,$b,chr(0x00));$ipad=str_pad('',$b,chr(0x36));$opad=str_pad('',$b,chr(0x5c));$k_ipad=$key^$ipad;$k_opad=$key^$opad;

php - 我如何使 $_GET 更安全。?

我正在使用get方法为评论系统执行一些操作,如批准、标记垃圾邮件、删除。我知道走这条路很不安全,但我无能为力。因为使用$_GET方法的原因是使用PHP_SELF在页面本身内执行操作,仅供引用,我也使用使用复选框的post方法来执行操作。现在为了让它有点安全,我想随机化数字或生成哈希或其他东西,然后比较它,获取id并执行操作我现在的代码有点像这样。">Unapprove">Approve|">Spam|">Edit|">Delete然后我使用这段代码执行操作..if(isset($_GET['approve'])){$id=intval($_GET['approve']);$query=

php - 如何在代理后面使用 file_get_contents()?

当我们使用file_get_contents时,PHP用什么来解析域名(本地DNS??)。我问是因为我遇到了这个错误:Warning:file_get_contents(http://external-domain.com)[function.file-get-contents]:failedtoopenstream:Aconnectionattemptfailedbecausetheconnectedpartydidnotproperlyrespondafteraperiodoftime,orestablishedconnectionfailedbecauseconnectedhos

PHP:我有一个关联数组(int => object),想对它进行排序

classDownTime{public$total,$longest,$count;}我有一个关联数组(键是一个id,值是DownTime对象)。我想按照$total排序我读过PHP:SortingArrays以及关于stackoverflow的一些其他问题。我明白了uasort会做的很好。但是,作为OOP方法,我更愿意在DownTime类中定义一个特殊函数(例如在C++中定义operator,或在Java中实现Comparable.compareTo()),而不是在调用某些排序函数时传递一个函数。 最佳答案 您可以在DownTi

php - 使用 get_meta_tags() 和 get_headers() 进行异常处理?

在PHP中,我使用get_meta_tags()和get_headers(),但是,当出现404时,这两个函数会抛出警告。我有什么办法可以捕获它吗?谢谢! 最佳答案 get_headers不会在404上抛出警告/错误,但get_meta_tags会。所以你可以检查标题响应并在它不正常时做一些事情:$url='http://www.example.com/';$headers=array();$metatags=array();$validhost=filter_var(gethostbyname(parse_url($url,PHP

php - 如何使用 file_get_contents() 在 Windows NT Auth 之后检索文件

我有一个设置,其中LAMP服务器需要从位于WindowsNT身份验证后面的另一台服务器IIS的javascript文件中检索输出。没有适当的身份验证,我可以只使用file_get_contents()来检索我需要的javascript文件。但是,如果使用WindowsNT身份验证,这会失败。有人知道如何模拟身份验证过程以允许PHP检索文件吗? 最佳答案 使用curl。functiongetUrl($url,$username=false,$password=false){$ch=curl_init();curl_setopt($ch

php - htaccess mod_rewrite 部分 url 到 GET 变量

我有一些这样的URL:http://plutov.by/post/cubique_zf_jqueryhttp://plutov.by/post/mysql_useful_queries如何在Apachemod_rewrite的帮助下打开下一页?http://plutov.by/post/main?title=cubique_zf_jqueryhttp://plutov.by/post/main?title=mysql_useful_queries此外,这个新的重写规则是否适用于“一个入口点重写”?RewriteEngineOnRewriteCond%{REQUEST_FILENAME}

PHP:file_get_contents 中的文件名不能为空

我想在开始之前指出,我是一个PHP新手,在最终决定我不知道我在用它做什么之前,我已经为此苦苦挣扎了一段时间。我认为我没有拼写错误或大写错误,例如thisguy但是,请原谅我乱七八糟的代码。$max_allowed_file_size){$errors.="\nSizeoffileshouldbelessthan$max_allowed_file_size";}//------Validatethefileextension-----$allowed_ext=false;for($i=0;$ialert('Thankyouforthemessage.Wewillcontactyousho