草庐IT

function_format

全部标签

php - 通知 : Undefined index: HTTP_X_FORWARDED_FOR Error in Function

我收到通知:未定义索引:以下函数中的HTTP_X_FORWARDED_FOR:function_ip(){return(preg_match("/^([d]{1,3}).([d]{1,3}).([d]{1,3}).([d]{1,3})$/",$_SERVER['HTTP_X_FORWARDED_FOR'])?$_SERVER['HTTP_X_FORWARDED_FOR']:$_SERVER['REMOTE_ADDR']);} 最佳答案 您应该使用getenv()方法而不是$_SERVER。function_ip(){if(preg_

PHP "Warning: usort() [function.usort]: Invalid comparison function"排序

我有以下数据作为关联数组array'abc'=>array'label'=>string'abc'(length=3)'weight'=>float3'wsx'=>array'label'=>string'wsx'(length=3)'weight'=>float1'qay'=>array'label'=>string'qay'(length=3)'weight'=>float1'http://test.com'=>array'label'=>string'http://test.com'(length=15)'weight'=>float0'Nasi1'=>array'label'=

php - fatal error : Call to undefined function easter_date()

我正在尝试获取今年的easter_date。这是我的代码:当我执行代码时出现以下错误:fatalerror:在中调用未定义的函数easter_date()我的php版本是5.3.3。我正在使用Linux(Ubuntu)。您知道缺少什么吗? 最佳答案 如果您使用基于php:7.1的Dockerfile,您可以轻松安装calendar扩展:RUNdocker-php-ext-installcalendar&&docker-php-ext-configurecalendar 关于php-fat

php - 代码点火器/PHP : Format db query as an array

$this->db->select('id,user_id')->from('be_users')->where('id',$user_id);$data['user_individual']=$this->db->get();如果这是我的数据库查询,我如何获得一个数据库行的数组...即。我想做一些像$data['user_individual']['id']->format_as_array... 最佳答案 CodeIgniter提供了几种方法来执行查询结果。参见此处:https://codeigniter.com/user_gu

PHP 问题 : password_hash function is not able to generate a salt

我正在创建一个用户注册服务提供商,我正在使用password_hash函数来散列提供的用户密码。以下是用于创建散列字符串的代码部分:publicfunctiongenerateHash($string){returnpassword_hash($string,PASSWORD_BCRYPT);}正如我从PHP手册中了解到的那样,我们不应该生成我们的盐,而是让password_hash函数来处理它以提高安全性。但是,当我尝试创建新用户时,我收到以下警告:Warning:password_hash():Unabletogeneratesalt应用程序创建了用户,但由于上述问题,不会生成哈希

php - preg_match() [function.preg-match] : Unknown modifier

很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visitthehelpcenter.关闭10年前。我收到此错误消息:preg_match()[function.preg-match]:Unknownmodifier'='in/home/public_html/checkem.phponline13当我转到以下行时,我得到了这个:我已将ereg更改为preg_match然后用//包装代码,因为ereg出现了作为弃用。我仍然是编码的初学者,非常感谢任何帮助。

php - 第 332 行的 fatal error : Call to a member function getId() on a non-object in C:\wamp\www\magentno\lib\Varien\Data\Tree\Dbp. php

我正在使用Magento1.8.0.0,我通过本地主机在WAMP服务器上安装了一个测试版本,当我想添加类别时,出现下一个错误:fatalerror:在C:\wamp\www\magentno\lib\Varien\Data\Tree\Dbp.php中的非对象上调用成员函数getId()第332行我还没有开店,因为我需要那个类别。我已经在出现错误的行中添加了tryandcatch代码。这是给出错误的代码:publicfunctionloadEnsuredNodes($category,$rootNode){$pathIds=$category->getPathIds();$rootNod

PHP 日志 : Warning format

PHP日志格式不包括警告的日期。例如PHPWarning:Cannotmodifyheaderinformation...没有任何警告发生的日期。有没有办法更改警告格式,或者至少在日志中包含日期?(如果重要,使用php-fpm)。 最佳答案 当然,您始终可以使用set_error_handler定义自己的错误处理程序.简化示例:functionhandler($errno,$errstr,$errfile,$errline,$errcontext){$message=date('Y-m-dH:i:s').":$errstrin$er

php - 使用 gzopen() : undefined function 时出现 fatal error

我想使用gzopen函数打开一个.gz文件,但出现了这个错误:Fatalerror:Calltoundefinedfunctiongzopen()这里是关于我的安装的一些细节:OS:Ubuntu10.04uptodateApacheversion:2.2.14PHP:5.2.10-2ubuntu6在phpinfo()的Zlib部分,我得到了这个:ZLibSupportenabledStreamWrappersupportcompress.zlib://StreamFiltersupportzlib.inflate,zlib.deflateCompiledVersion1.2.3.3Li

php - 在 5.3 之前的 PHP 中使用 "create_function"比较器进行排序?

我以前从未在PHP中使用过匿名函数,但我发现了一段使用匿名函数对对象进行排序的代码usort($numTurnsPerUser,build_sorter('turns'));functionbuild_sorter($key){returnfunction($a,$b)use($key){returnstrnatcmp($a[$key],$b[$key]);};}此代码将按键对对象进行排序(我传入“turns”)。例如,一个看起来像这样的对象:(用JSON编写,只是为了便于阅读)$numTurnsPerUser={"31":{"turns":15,"order":0},"36":{"t