草庐IT

de_date_created

全部标签

PHP 的 create_function() 与仅使用 eval()

在PHP中,您有create_function()函数,它创建一个唯一的命名lambda函数,如下所示:$myFunction=create_function('$foo','return$foo;');$myFunction('bar');//Returnsbar这实际上是不是更好(除了更容易)然后做:do{$myFunction='createdFunction_'.rand();}while(function_exists($myFunction));eval("function$myFunction(\$foo){return\$foo;}");$myFunction('bar

php - com_create_guid() 未定义 : returns fatal error

我在我的专用linux服务器上使用PHP55.2.6(cli)(built:May7200801:11:22)Copyright(c)1997-2008ThePHPGroupZendEnginev2.2.0,Copyright(c)1998-2008ZendTechnologies但com_create_guid函数对我不起作用,它返回此错误消息Fatalerror:Calltoundefinedfunctioncom_create_guid()in/var/www/html/mysite/application/modules/consultant/models/Consultant

php - 警告 : date() expects parameter 2 to be long, 中给出的字符串

我在我的数据库的car_detail.php页面上不断收到这个错误Warning:date()expectsparameter2tobelong,stringgivenin/home/speedycm/public_html/speedyautos/cars_class.phponline228*cars_class.php在第228行读取这个$this->expiry_date=date("m/d/Y",$rows['expiry_date']);我该如何解决这个问题? 最佳答案 date()需要一个unix时间戳...我想您正在

php - 发生客户端错误 : Could not create storage directory:/tmp/Google_Client/00

此错误对YoutubeAPIv3.0意味着什么:Aclienterroroccurred:Couldnotcreatestoragedirectory:/tmp/Google_Client/00我在Google的文档中使用PHPYoutubeAPI找到here. 最佳答案 我在不更改GoogleAPI的任何行的情况下解决了这个问题。在您的PHP代码中,您只需要指定缓存文件夹所在的位置:$config=newGoogle_Config();$config->setClassConfig('Google_Cache_File',arra

PHP Date - 如何添加一个字符串来分隔日期和时间

我想显示类似这样的日期和时间格式“May23at12:30pm”。我在PHP手册中看到并发现://Printssomethinglike:Monday8thofAugust200503:12:46PMechodate('ljS\ofFYh:i:sA');修改后得到echodate('Mj\ofh:ia');它给我“5月23日中午12:30”但是当我用at替换of时,它给了我"May23a2308:26pm"。我不知道出了什么问题。 最佳答案 您需要对a和t进行转义,因为它们在date()中用作格式设置选项时具有特殊含义echodat

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 "first date of this week"上个月返回

运行var_dump(new\DateTime('firstdayofthisweek'));9月1日返回https://3v4l.org/GIPKR这是一个错误吗?有什么解决方法吗? 最佳答案 请尝试以下代码:var_dump(new\DateTime('mondaythisweek')); 关于PHP"firstdateofthisweek"上个月返回,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co

php - 在 date_sun_info() 什么是 Transit

我理解SunTransit的意思是太阳从日出位置移动到日落位置所花费的时间date_sun_info()凌日似乎返回当天太阳恰好在日出和日落位置之间的中点。$sun_info=date_sun_info(strtotime("2006-12-12"),31.7667,35.2333);foreach($sun_infoas$key=>$val){echo"$key:".date("H:i:s",$val)."\n";}上面的例子会输出:sunrise:05:52:11sunset:15:41:21transit:10:46:46civil_twilight_begin:05:24:08

php - strtotime 和 date 输出不正确

我无法为数据库中保存的日期回显正确的unix时间戳。$activeWorkRow['WorkDate']="9/24/20151:45:53PM";$locateDate=$activeWorkRow['WorkDate'];$locateDate=str_replace('/','-',$locateDate);//$locateDate=date('m-d-Y',strtotime($locateDate));//$locateDate=strtotime(date($locateDate));echo$locateDate."";输出:9-24-20151:45:53PM下一步:

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