function DateAdd($date, $int, $unit = "d") { //Increase of time (can also be improved to hours, minutes and seconds) You can increase it and make it up when you have time) $dateArr = explode("-", $date); $value[$unit] = $int; return date("Y-m-d", mktime(0,0,0, $dateArr[1] + $value['m'], $dateArr[2] + $value['d'], $dateArr[0] + $value['y'])); } function GetWeekDay( $date) { //Calculate the day of the week for the given date $dateArr = explode("-", $date); return date("w", mktime(0,0,0,$dateArr[1] ,$dateArr[2],$dateArr[0])); } ?> Detailed source reference: http://www.jb51.net/article/22199.htm
function check_date( $date) { //Check whether the date is a legal date $dateArr = explode("-", $date); if (is_numeric($dateArr[0]) && is_numeric($dateArr[1]) && is_numeric($dateArr [2])) { return checkdate($dateArr[1],$dateArr[2],$dateArr[0]); } return false; } function check_time($time) { //Check whether the time is Legal time $timeArr = explode(":", $time); if (is_numeric($timeArr[0]) && is_numeric($timeArr[1]) && is_numeric($timeArr[2])) { if ( ($timeArr[0] >= 0 && $timeArr[0] <= 23) && ($timeArr[1] >= 0 && $timeArr[1] <= 59) && ($timeArr[2] >= 0 && $timeArr[2] <= 59)) return true; else return false; } return false; } Detailed source reference: http://www.jb51.net/article /22199.htm
function DateDiff($date1, $date2, $unit = "") { //Time comparison function, returns the number of seconds, minutes, hours or days between two dates switch ($unit ) { case 's': $dividend = 1; break; case 'i': $dividend = 60; break; case 'h': $dividend = 3600; break; case ' d': $dividend = 86400; break; default: $dividend = 86400; } $time1 = strtotime($date1); $time2 = strtotime($date2); if ($time1 && $ time2) return (float)($time1 - $time2) / $dividend; return false; } ?> Detailed source reference: http://www.jb51.net/article/22199.htm
Time comparison issue Give a simple example: For example, a forum uses a new image to mark the posts published on that day. Method 1: Copy the code as follows:
//$db->rows[$i][date] is the datetime field value in the database. $today=time(); $theDay= date("Y-m-d H:i:s",$today-24*3600); $newTag=$db->rows[$i][date]>=$theDay?"":""; //Method 2: $newTag=$db->rows[$i][date]>=date("Y-m-d 00:00:00 ")?"":""; ?>
Copy the code as follows: //Extract the variables submitted by the page and browser, the function Equivalent to opening global variables in PHP.INI
Copy the code as follows: //Quick page redirection
function turntopage($url="index.php",$ info = "The page is redirecting...",$second=2){ print "nnThe page is redirecting....n"; print " n"; print "n"; print "nn"; print "
Copy the code as follows: //Convert each row and column of the HTML table into an array and collect table data < ? function get_td_array($table) { $table = preg_replace("'
//Get the content in the specified tag function get_tag_data($str, $start, $end){ If ( $ start == '' || $end == '' ){ return $str[0]; } //Convert each row of the HTML table to a CSV format array function get_tr_array($table) { $table = preg_replace("'
]*?> 'si",'"',$table); $table = str_replace("
",'",',$table); $table = str_replace(""," {tr} ", $ table); // Remove the html mark
//Convert each row and column of the HTML table into an array and collect table data function get_td_array($table) { ;'si","",$table); $table = preg_replace("'
//Static page generation function function phptohtm($filefrom,$fileto,$u2u=1){ if($u2u==1){ $data=PHP_Read($ filefrom); }else{ $data=$filefrom; } PHP_Write($fileto,$data); return true; } ?>
Specify condition information quantity retrieval function
//Specify condition information quantity retrieval function function rec_exist($table,$where){ $query="select count(*) as num from $table ".$where; $result=mysql_query ($query) or die(nerror(1)); $rowcount=mysql_fetch_array($result); $num=$rowcount["num"]; if ($num==0){ return false; } Return $num; } ?>
Directory deletion function
//Directory deletion function function del_DIR($directory){ $mydir=dir($directory) ; while($file=$mydir->read()){ if((is_dir("$directory/$file")) AND ($file!=".") AND ($file!=".." )){ del_DIR("$directory/$file"); }else{ if(($file!=".") AND ($file!="..")){ unlink("$directory /$file"); //echo "unlink $directory/$file ok "; } } }
$mydir->close(); rmdir($directory); //echo " rmdir $directory ok "; } ?>
Directory name legality detection function
// Directory name legality detection function isen($str){ $ret=""; for ($i=0;$i $p=ord(substr($str,$i,1)); if(($p<48 & $p!=45 & $p!=46) || ($ p>57 & $p<65) || ($p>90 & $p<97 & $p!=95) || $p>122){ nerror("Does not meet the specification! "); } $ret.=chr($p); } return $ret; } ?>
paging function
//分页函式 function splitlist($HALT,$LRLIST,$ECHOCNT,$paper,$table,$where,$page_id,$userid){ global $splitstr,$sumcnt; if($paper=="" || $sumcnt==""){ $query = "select count(*) as num from $table $where"; $result = mysql_query($query); $row = mysql_fetch_array($result); $sumcnt=$row["num"]; if($sumcnt==0){ nerror("该版内还没有选择发布新闻 !"); } $paper=1; }
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a
Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application.
Data persists only for the subsequent request by default:
$request-
This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev
Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive.
The basic implementation provides a variety of response type shortcuts:
use Illuminate\Support\Facades\Http;
Http::fake([
'google.com' => 'Hello World',
'github.com' => ['foo' => 'bar'],
'forge.laravel.com' =>
The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.
Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom
The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio
In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov