草庐IT

php - jQuery/AJAX : How to determine when a host is offline

我有一个jQuery脚本可以轮询我的服务器以获取新数据,但如果由于任何原因失败,它需要显示一条错误消息。这是我的AJAX请求:$.ajax({url:"query.php",//ThisjustrunssomeMySQLqueriesandechostheresultscache:false,error:function(){$(".status").text("Serverisoffline.");},success:function(html){//Everythingwentfine,appendqueryresultstodiv}});我发现如果重命名query.php使其无法

PHP is_readable 为不可读文件返回 true

我有一个图像处理器PHP脚本,它包含以下代码:if(!is_dir($fullFile)){if(is_readable($fullFile)){$im=getimagesize($fullFile);//WillbeFALSEifnotanimage在某些情况下,脚本将在getimagesize处失败并出现以下错误:getimagesize(/path/to/file.jpg)[function.getimagesize]:failedtoopenstream:Permissiondeniedatwww.yada.yada/page.php在这种情况下,/path/to/file.j

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

PhpMyAdmin The session id is too long and Session object destruction failed 警告消息

以下是完整的警告信息:Warningin.\libraries\session.inc.php#101session_start():Thesessionidistoolongorcontainsillegalcharacters,validcharactersarea-z,A-Z,0-9and'-,'Backtrace.\libraries\session.inc.php#101:session_start().\libraries\common.inc.php#352:require(.\libraries\session.inc.php).\index.php#12:requir

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 - 运行 phpcs 时,错误 : Referenced sniff "PHPCompatibility" does not exist is coming

我想运行phpcs工具,但是这个错误来了,错误:引用的嗅探“PHPCompatibility”不存在我运行了phpcs-i。这给了我,安装的编码标准是PEAR、PSR1、Zend、Squiz、PSR12、PSR2、MySource和PHPCompatibility。但总是会出现这个错误,错误:引用的嗅探“PHPCompatibility”不存在。有什么原因吗? 最佳答案 根据当前PHPCompatibilityCodingStandard执行此步骤所需的文档:打开您的composer.json文件并将以下行添加到:"require-

php - 使用 vfsStream 测试 move_uploaded_file 和 is_uploaded_file

我尝试使用PHPUnit和vfsStream测试move_uploaded_file和is_uploaded_file。他们总是返回错误。publicfunctiontestShouldUploadAZipFileAndMoveIt(){$_FILES=array('fieldName'=>array('name'=>'file.zip','type'=>'application/zip','tmp_name'=>'vfs://root/file.zip','error'=>0,'size'=>0,));vfsStream::setup();$vfsStreamFile=vfsStre

apache - SetEnv TZ 与 date.timezone

在Apache的SetEnvTZ(.htaccess)和PHP的date.timezone(php.ini)中设置时区有什么区别?我无法检测到如何使用SetEnvTZ。我尝试将SetEnvTZ设置为一个值并将date.timezone设置为另一个时区,但只有后者date.timezone似乎有任何效果在网页上。我还想知道Apacheconfiguratoins和PHP配置对于相同的事情如何影响服务器,例如哪个覆盖哪个。 最佳答案 网址http://www.php.net/manual/en/function.date-default

php - Symfony2 中的设计模式 : is EventDispatcher a Mediator or Event Aggregator?

来自Symfony2的EventDispatcher组件文档:TheSymfony2EventDispatchercomponentimplementstheMediatorpatterninasimpleandeffectivewaytomakeallthesethingspossibleandtomakeyourprojectstrulyextensible.我一直在阅读EventAggregator和中介者模式及其differences.在我看来,EventAggregator是Mediator的一个特例,它使用事件来促进通信,并且内部没有任何业务逻辑。另一方面,调解器更通用,可

PHP date() 打印 24 :00 instead of 00:00

PHPdate("H:i(d.m.Y)",$timestamp)函数将精确的午夜表示为第二天的00:00。但我需要它来表示前一天的24:00。是否可以在不编写全新的date()解析器函数的情况下完成?编辑:为什么我需要这种“奇怪”的格式?因为我的客户要求它。在我的国家(CZ),有时会使用24:00来表示确切的午夜。edit2:我当前的“肮脏”解决方案是:(不适用于所有可能的格式字符串)functiondate_24midnight($format,$ts){if(date("Hi",$ts)=="0000")returnpreg_replace('/23:59/',"24:00",da