草庐IT

php - PHP 的字母等效 is_numeric

我正在寻找一个与is_numeric按字母顺序等效的函数。如果字符串中只有字母,它将返回true,否则返回false。PHP中是否存在内置函数? 最佳答案 你想要ctype_alpha() 关于php-PHP的字母等效is_numeric,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/2323105/

php - strtotime() & date() 将日期转换为与以前相同的格式时出现奇怪的行为

我必须将日期格式转换为mm-dd-yyyy我不知道当前日期格式是什么,它是动态的所以如果我有动态日期格式已经在mm-dd-yyyy然后date()函数返回低于outout$date='02-13-2011';echodate('m-d-Y',strtotime($date));输出是01-01-1970?>http://codepad.org/AFZ6jel7所以我必须检查日期是否已经在mm-dd-yyyy中,然后不应用日期格式。还有其他方法吗?可能在这些函数中传递另一个参数或类似的东西。谢谢。 最佳答案 我强烈怀疑这是导致问题的原

即使在设置 date_default_timezone_set 之后,PHPExcel 也会得到错误的时区

我正在使用http://phpexcel.codeplex.com在我的一个项目中,我遇到了一个问题。我想在单元格中写入time()值,我正在这样做:functionwriteTimeLine($objActiveSheet,&$lineNumber,$timeStart,$timeEnd,$duration,$category,$client,$date,$comment){$objActiveSheet->setCellValue('A'.$lineNumber,PHPExcel_Shared_Date::PHPToExcel($timeStart));$objActiveShee

php - date_parse_from_format 到 unix 时间戳

我对date_parse_from_format()方法有疑问:$parsed=date_parse_from_format("YdMH:iT",'201228Nov21:00CET');Returnsassociativearraywithdetailedinfoaboutgivendate.这将返回一个包含一些日期信息的数组。但是有什么方法可以将它转换为unix时间戳吗? 最佳答案 约翰,下面是如何在您的场景中实现mktime的具体示例:$parsed=date_parse_from_format("YdMH:iT",'2012

php - 这是 PHP date() 错误,还是我的代码有问题?

我有两个箭头图像,一个向后递增月份,一个通过href向前递增。if(ISSET($_GET["month"])){$month_index=$_GET["month"];}else{$month_index=0;}$month=strtotime("+".$month_index."month");?>...>LogbookCalendarfor>问题是,当2015年2月出现时,date()返回“2015年3月”——因此$month_index=6和$month_index=7都是三月。我在http://writecodeonline.com/php/上运行了这段代码:date_def

PHP : Is there a way, 把这个 if/elseif/else 语句写得更短?

所以过去几天我一直在积极学习PHP,并且为了练习,我编写了PHP脚本,它采用HTML表单值。我试着写脚本,我有5个人,你必须输入你的名字和姓氏。如果它与五个人中的一个相匹配,则发送一条消息,如果不匹配,则发送另一条消息。这是(没有表单部分,只有PHP):$first=$_POST["first"];$last=$_POST["last"];if($first=="Jeb"){if($last=="Jeb"){print"Hello!";}else{print"Idontknowyou!";}}elseif($first=="Bob"){if($last=="Bob"){print"He

php - Laravel Eloquent : is SQL injection prevention done automatically?

给定示例代码(Message是一个Eloquent模型。):publicfunctionsubmit(Request$request){$this->validate($request,['name'=>"required","email"=>"required"]);//databaseconnection$message=newMessage;$message->name=$request->input("name");$message->email=$request->input("email");$message->save();}Eloquent是否使用参数化查询(如PDO)

php - 弃用 : Function session_register() is deprecated and Cannot modify header information

我用sql创建了一个简单的登录系统它有4个主要组件index-询问用户名并通过checklogin-检查凭据登录成功首页-登录成功后的登陆页面错误生成在文章末尾给出Index.phpasksforusernameandpassNottinghamUni AuthenticationUsernamePassword   checklogin.phpchecksforthecredentialsIfitssuccessitgoestohomepage.phplogsuccess.phpisbelowLoginSuccessfulthesecodesa

PHP "list"问题 : Why the result is in reverse order?

您能否详细解释为什么出现此代码:$arr=array(1,2,3);list($result[],$result[],$result[])=$arr;print_r($result);结果:Array([0]=>3[1]=>2[2]=>1)? 最佳答案 请参阅list的PHP文档:list()assignsthevaluesstartingwiththeright-mostparameter.Ifyouareusingplainvariables,youdon'thavetoworryaboutthis.Butifyouareusi

php - is_array() 的区别

我有一段代码,其中变量可以是数组或只是一个字符串。if(!is_array($relation['display_name'])){//dosomethingwith$relation['display_name']}else{foreach($relation['display_name']as$display_name){//dothesamewith$display_name}}这当然有效——但不是很好。而且我将不得不这样做很多次。有更好的方法吗? 最佳答案 你可以这样做:foreach((array)$relation['d