Heim Backend-Entwicklung PHP-Tutorial Sammlung gängiger PHP-Funktionen

Sammlung gängiger PHP-Funktionen

Nov 23, 2016 pm 03:21 PM

Ich habe kürzlich nach PHP gesucht und es gespeichert.
Quelle: PHP-Quellcode-Netzwerk - Open Source-Programme (Open Source)


Inhalt:
Funktion GetIP() { //Get IP
if ( $_SERVER["HTTP_X_FORWARDED_FOR"])
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
else if ($_SERVER["HTTP_CLIENT_IP"])
$ip = $_SERVER["HTTP_CLIENT_IP"] ;
else if ($_SERVER["REMOTE_ADDR"])
$ip = $_SERVER["REMOTE_ADDR"]
else if (getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv( " HTTP_X_FORWARDED_FOR");
else if (getenv("HTTP_CLIENT_IP")
$ip = getenv("HTTP_CLIENT_IP");
else if (getenv("REMOTE_ADDR"))
$ip = getenv ("REMOTE_ADDR");
else
$ip = "Unknown";
return $ip; // /www.jb51.net/article/22199.htm


function DateAdd($date, $int, $unit = "d") { //Erhöhen der Zeit (Es kann auch verbessert werden, um Stunden, Minuten und Sekunden zu erhöhen und sie hinzuzufügen, wenn Sie Zeit haben)
$dateArr = explosion("-", $date); $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) { //Berechne den Wochentag, an dem das angegebene Datum ist
$dateArr = explosion("-", $date);
return date("w", mktime(0,0,0,$dateArr[1],$dateArr[2],$dateArr[0])); >
Detaillierte Quellenangabe:http://www.jb51.net/article/22199.htm

function check_date($date) { //Überprüfen Sie, ob das Datum ist ein gültiges Datum
$dateArr = explosion( "-", $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) { //Überprüfen Sie, ob die Zeit die zulässige Zeit ist
$timeArr = explosion(":", $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;
}
Detaillierte Quellenangabe: http://www.jb51.net/article/22199.htm


function DateDiff($date1, $date2, $unit = "") { //Zeitvergleichsfunktion, gibt die Differenz in Sekunden, Minuten, Stunden oder Tagen zwischen zwei Daten zurück
switch ($unit) {
case 's':
$dividend = 1;
Fall 'i':
Fall 'h':
Bruch
case 'd':
$dividend = 86400;
default:
$dividend = 86400;
$time1 = strtotime ($date1); 🎜>if ($time1 && $time2)
return (float)($time1 - $time2) / $dividend;
return false;
?> : http://www.jb51.net/article/22199.htm


Methode 1: header("Location: index.php"); : echo "window.location ="$PHP_SELF";"; Methode 3: echo "";
?>
Detaillierte Quellenangabe: http://www.jb51.net/article/22199.htm

PHP-Umleitung
Codecode wie folgt kopieren :
Methode 1: header(„Location: index.php“); ";
Methode 3: echo "";
?>

Zugriff erhalten Der Browser-
-Code lautet wie folgt:
function browse_infor()
{
$browser="";$browserver=""; Lynx“, „MOSAIC“, „AOL“, „Opera“, „JAVA“, „MacWeb“, „WebExplorer“, „OmniWeb“);
$Agent = $GLOBALS["HTTP_USER_AGENT"];
für ($i=0; $i<=7; $i )
{
if (strpos($Agent,$Browsers[$i])) 

$browser = $Browsers[$i]; 
$browserver =""; 


if (ereg("Mozilla",$Agent) && !ereg("MSIE",$Agent)) 

$temp =explode("(", $Agent); $Part=$temp[0]; 
$temp =explode("/", $Part=$browserver=$temp[1]; browserver); $browserver=$temp[0]; 
$browserver =preg_replace("/([d.] )/","1",$browserver); 
$browser = "Netscape Navigator"; 

if (ereg("Mozilla",$Agent) && ereg("Opera",$Agent)) 

$temp = explosion("(", $Agent); $Part=$temp[1]; 
$temp =explode(")", $Part=$temp[1]; 
$temp = explosion(" ",$browserver);$browserver=$temp[2]; 
$browserver =preg_replace("/([d.] )/","1",$browserver); 
$browserver = " $browserver"; 
$browser = "Opera"; 

if (ereg("Mozilla",$Agent) && ereg("MSIE",$Agent)) 

$temp = explosion("(", $Agent); $Part=$temp[1]; 
$temp = explosion(";",$Part); $Part=$temp[1]; 
$temp = explosion(" ",$Part);$browserver=$temp[2]; 
$browserver =preg_replace("/([d.] )/","1",$browserver);
$browserver = " $browserver"; 
$browser = "Internet Explorer"; 

if ($browser!="") 

$browseinfo = "$browser$browserver"; 

else 

$browseinfo = "Unknown"; 

return $browseinfo; 

//调用方法$browser=browseinfo() ;直接返回结果 
?> 
详细出处参考:http://www.jb51.net/article/22199.htm 

获取访问者操作系统 
复制代码 代码如下: 
function osinfo() { 
$os=""; 
$Agent = $GLOBALS["HTTP_USER_AGENT"]; 
if (eregi('win',$Agent) && strpos($Agent, '95')) { 
$os="Windows 95"; 

elseif (eregi('win 9x',$Agent) && strpos($Agent, '4.90')) { 
$os="Windows ME"; 

elseif (eregi('win',$Agent) && ereg('98',$Agent)) { 
$os="Windows 98"; 

elseif (eregi('win',$Agent) && eregi('nt 5.0',$Agent)) { 
$os="Windows 2000"; 

elseif (eregi('win',$Agent) && eregi('nt',$Agent)) { 
$os="Windows NT"; 

elseif (eregi('win',$Agent) && eregi('nt 5.1',$Agent)) { 
$os="Windows XP"; 

elseif (eregi('win',$Agent) && ereg('32',$Agent)) { 
$os="Windows 32"; 

elseif (eregi('linux',$Agent)) { 
$os="Linux"; 

elseif (eregi('unix',$Agent)) { 
$os="Unix"; 

elseif (eregi('sun',$Agent) && eregi('os',$Agent)) { 
$os="SunOS"; 

elseif (eregi('ibm',$Agent) && eregi('os',$Agent)) { 
$os="IBM OS/2"; 

elseif (eregi('Mac',$Agent) && eregi('PC',$Agent)) { 
$os="Macintosh"; 

elseif (eregi('PowerPC',$Agent)) { 
$os="PowerPC"; 

elseif (eregi('AIX',$Agent)) { 
$os="AIX"; 

elseif (eregi('HPUX',$Agent)) { 
$os="HPUX"; 

elseif (eregi('NetBSD',$Agent)) { 
$os="NetBSD"; 

elseif (eregi('BSD',$Agent)) { 
$os="BSD"; 

elseif (ereg('OSF1',$Agent)) { 
$os="OSF1"; 

elseif (ereg('IRIX',$Agent)) { 
$os="IRIX"; 

elseif (eregi('FreeBSD',$Agent)) { 
$os="FreeBSD"; 

if ($os=='') $os = "Unknown"; 
return $os; 

//调用方法$os=os_infor() ; 
?> 

详细出处参考:http://www.jb51.net/article/22199.htm 

文件格式类 
复制代码 代码如下: 
< ? 
$mime_types = array( 
'gif' => 'image/gif', 
'jpg' => 'image/jpeg', 
'jpeg' => 'image/jpeg', 
'jpe' => 'image/jpeg', 
'bmp' => 'image/bmp', 
'png' => 'image/png', 
'tif' => 'image/tiff', 
'tiff' => 'image/tiff', 
'pict' => 'image/x-pict', 
'pic' => 'image/x-pict', 
'pct' => 'image/x-pict', 
'tif' => 'image/tiff', 
'tiff' => 'image/tiff', 
'psd' => 'image/x-photoshop', 
'swf' => 'application/x-shockwave-flash', 
'js' => 'application/x-javascrīpt', 
'pdf' => 'application/pdf', 
'ps' => 'application/postscrīpt', 
'eps' => 'application/postscrīpt', 
'ai' => 'application/postscript', 
'wmf' => 'application/x-msmetafile', 
'css' => 'text/css', 
'htm' => 'text/html', 
'html' => 'text/html', 
'txt' => 'text/plain', 
'xml' => 'text/xml', 
'wml' => 'text/wml', 
'wbmp' => 'image/vnd.wap.wbmp', 
'mid' => 'audio/midi', 
'wav' => 'audio/wav', 
'mp3' => 'audio/mpeg', 
'mp2' => 'audio/mpeg', 
'avi' => 'video/x-msvideo', 
'mpeg' => 'video/mpeg', 
'mpg' => 'video/mpeg', 
'qt' => 'video/quicktime', 
'mov' => 'video/quicktime', 
'lha' => 'application/x-lha', 
'lzh' => 'application/x-lha', 
'z' => 'application/x-compress', 
'gtar' => 'application/x-gtar', 
'gz' => 'application/x-gzip', 
'gzip' => 'application/x-gzip', 
'tgz' => 'application/x-gzip', 
'tar' => 'application/x-tar', 
'bz2' => 'application/bzip2', 
'zip' => 'application/zip', 
'arj' => 'application/x-arj', 
'rar' => 'application/x-rar-compressed', 
'hqx' => 'application/mac-binhex40', 
'sit' => 'application/x-stuffit', 
'bin' => 'application/x-macbinary', 
'uu' => 'text/x-uuencode', 
'uue' => 'text/x-uuencode', 
'latex'=> 'application/x-latex', 
'ltx' => 'application/x-latex', 
'tcl' => 'application/x-tcl', 
'pgp' => 'application/pgp', 
'asc' => 'application/pgp', 
'exe' => 'application/x-msdownload', 
'doc' => 'application/msword', 
'rtf' => 'application/rtf', 
'xls' => 'application/vnd.ms-excel', 
'ppt' => 'application/vnd.ms-powerpoint', 
'mdb' => 'application/x-msaccess', 
'wri' => 'application/x-mswrite', 
); 
?> 

详细出处参考:http://www.jb51.net/article/22199.htm 

php生成excel文档 
复制代码 代码如下: 
< ? 
header("Content-type:application/vnd.ms-excel"); 
header("Content-Disposition:filename=test.xls"); 
echo „test1t“; 
echo „test2tn“; 
echo „test1t“; 
echo „test2tn“; 
echo „test1t“; 
echo „test2tn“; 
echo „test1t“; 
echo „test2tn“; 
echo „test1t“; 
echo „test2tn“; 
echo „test1t“; 
echo „test2tn“; 
//改动相应文件头就可以输出.doc .xls等文件格式了 
?> 

Detaillierte Quellenangabe: http://www.jb51.net/article/22199.htm

Zeitvergleichsproblem
Geben Sie ein einfaches Beispiel: Beispielsweise verwendet ein Forum neue Bilder, um dort veröffentlichte Beiträge zu markieren Tag einmal.
Methode 1:
Kopieren Sie den Code wie folgt:
< >$ today=time();
$theDay=date("Y-m-d H:i:s",$today-24*3600);
$newTag=$db->rows[$i][ date] >=$theDay?":"; rows[ $i][date]>=date("Y-m-d 00:00:00")?"":""; >

Kopieren Sie den Code wie folgt:
/Von der Seite und dem Browser übermittelte Variablen extrahieren, was dem Öffnen globaler Variablen in PHP.INI entspricht
@extract ($_SERVER, EXTR_SKIP);
@extract($_SESSION, EXTR_SKIP);
@extract($ _GET, EXTR_SKIP );
@extract($_ENV, EXTR_SKIP);

Kopieren Sie den Code wie folgt:
//Dateifunktion
function readfromfile($file_name) {
if (file_exists($file_name)) {
$filenum=fopen($file_name,"r"); >$file_data =fread($filenum, filesize($file_name));
fclose($filenum);
return $file_data; 🎜>? >

Kopieren Sie den Code wie folgt:
//Dateifunktion schreiben
$filenum=fopen($file_name,$method);
flock($filenum,LOCK_EX);
$file_data=fwrite($filenum,$data); ;
return $file_data;
?>

Kopieren Sie den Code wie folgt:
//Quick Page Turntopage( $url=" index.php",$info = "Die Seite leitet weiter...",$second=2){
print "nnDie Seite leitet weiter. ...</ title>n"; <br>print "<meta http-equiv="refresh" content="$second;url=$url">n"; <br>print "<style type="text/css ">n<!--n"; <br/>print "td { Font-family: "Verdana", "Arial";font-size: 12px}n"; <br/>print " A {COLOR: #000000 ; TEXT-DECORATION: none}n"; <br/>print "-->n</style>n"; <br>print "</head>n<body>n"; <br>print "< ;table width="100%" border="0" align="center">n"; <br>print " <tr>n"; ="200"> </td>n"; <br>print " </tr>n"; <br>print " <tr>n"; <br>print " <td align=" center">n" <br>print " <table width="60%" border="0" cellpadding="8" bgcolor="#AA9FFF">n"; ;n"; <br>print " <td height="30" align="center">Informationen zur Seitenumleitungsaufforderung</td>n"; <br>print " </tr>n"; <br>print " < tr>n"; <br>print " <td align="center">$info</td>n"; print " <tr> ;n"; <br>print " <td align="center">n"; <br>print " <a href="$url">Wenn Ihr Browser keine automatische Unterstützung bietet springen, bitte klicken Sie hier</a></td>n"; <br>drucken " </tr>n"; <br>drucken " </tr>n"; <br>drucken " < /table> ;</td>n"; <br>print " </tr>n"; <br>print " <tr>n"; <br>print " <td height="200"> ; < ;/td>n"; <br>print " </tr>n"; <br>print "</table>n"; <br>print "</body>n</html> "; <br>exit; <br>?> <br><br>Generieren Sie eine Zufallszeichenfolgenfunktion <br>Kopieren Sie den Code wie folgt: <br><? <br/>function random($length) { <br/>$ hash = @#@#;$chars = @#ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz@#; <br/>$max = strlen($chars) - 1; <br/>mt_srand((double)microtime() * 1000000); <br/>for($i = 0; i < ; $length; $i ) { <br/>$hash .= $chars[mt_rand(0, $max)]; <br/>return $hash; ><br/>Schneiden Sie eine Zeichenfolge einer bestimmten Länge aus (diese Funktion gilt für GB2312) <br/>Kopieren Sie den Code wie folgt: <br/><? <br/>function Wordscut($string, $length,$sss=0 ) { <br/>if(strlen($string) > $length) { <br>if($sss){ <br>$length=$length - 3; # ; <br>} <br>for($i = 0; $i < $length; $i ) { <br/>if(ord($string[$i]) > 127) { <br>$ Wordscut .= $string[$i].$string[$i 1]; <br>$i ; sonst { <br>$wordscut .= $string[$i]} <br> } <br>return $wordscut.$addstr; <br>} <br>return $string <br>} <br><br>Holen Sie sich die Client-IP-Adresse <br>Der Code lautet wie folgt: <br><? <br/>function GetIP(){ <br/>if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) <br/>$ip = getenv ("HTTP_CLIENT_IP"); <br/>else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) <br/>$ip = getenv("HTTP_X_FORWARDED_FOR"); "REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) <br/>$ip = getenv("REMOTE_ADDR" <br/>else if (isset($_SERVER[@#REMOTE_ADDR@#]) && $_SERVER[ @#REMOTE_ADDR@#] && strcasecmp($_SERVER[@#REMOTE_ADDR@#], "unknown")) <br/>$ip = $_SERVER[@#REMOTE_ADDR@#]; <br/>else <br/>$ip = "unknown"; <br/>return($ip); <br/>?> <br><br>Beurteilen Sie die E-Mail-Adresse <br>Der Code lautet wie folgt: <br><? >function checkEmail($inAddress) <br/>{ <br/>return (ereg("^([a-zA-Z0-9_-]) @([a-zA-Z0-9_-]) (.[a- zA-Z0-9_-]) ",$inAddress)); <br/>} <br/>?> <br><br>Paging (zwei Funktionen werden zusammen verwendet) <br><br>Der Code lautet wie folgt : <br><? <br/>function getpage($sql,$page_size=20) <br/>{ <br/>global $page,$totalpage,$sums; //out param <br/>$page = $_GET ["page "]; <br/>//$eachpage = $page_size; <br/>$pagesql = strstr($sql," from "); <br/>$pagesql = "select count(*) as ids ".$ facesql; <br/>$result = mysql_query($pagesql); <br/>if($rs = mysql_fetch_array($result)) $sums = $rs[0]; ); <br/>if((!$page)($page<1)) $page=1; startpos,$ page_size "; <br/>return $sql; <br/>} <br/>function showbar($string="") <br/>{ <br/>global $page,$totalpage; <br/>$out=" Total<font ".$totalpage."color=@#red@#><b>".$totalpage."</b></font>page"; <br>$linkNum =4; <br> $start = ($page-round($linkNum/2))>0 ? ($page-round($linkNum/2)) : "1"; linkNum/ 2))<$page round($linkNum/2)) : $totalpage=$start-1; <br/>if ($ page<>1) <br>$out .= "<a href=@#?page=1&&".$string."@#title=Erste Seite>Erste Seite</a> "; >if($start>1) <br>$out.="<a href=@#?page=".$prestart."@# title=Vorherige Seite>..<<< ;/a> "; <br>for($t=$start;$t<=$end;$t ) <br/>{ <br/>$out .= ($page==$t) ? "< Schriftart [". $t."]color=@#red@#><b>[".$t."]</b></font> " : "<a $thref=@ #?page= $t&&".$string."@#>$t</a> "; <br>} <br>if($end<$totalpage) <br/>$out.="<a href=@# ?page=".$nextend."&&".$string."@# title=Nächste Seite>>>..</a>"; <br>if($page< >$totalpage) <br>$out .= " <a href=@#?page=".$totalpage."&&".$string."@# title=last page>last page</a> ;"; out; <br/>?> <br><br>Erhalten Sie die ID der neu eingefügten Daten <br>Kopieren Sie den Code wie folgt: <br>mysql_insert_id (?> <br>Der Code lautet wie folgt: <br>//Holen Sie sich die aktuelle Skript-URL <br><?function get_php_url(){ <br/>if(!empty($_server["REQUEST_URI"])){ <br/>$scriptName = $_SERVER["REQUEST_URI"]; <br/>$nowurl = $scriptName; else{ <br/>$scriptName = $_SERVER["PHP_SELF"]; <br/>if(empty($_SERVER["QUERY_STRING"])) $nowurl = $scriptName; ".$_SERVER["QUERY_STRING"]; <br/>} <br/>return $nowurl; <br/>} <br/>?> <br><br>Der Code lautet wie folgt: <br>//Vollständig konvertieren -width Zahlen zu halbbreiten Zahlen <br><? <br/>function GetAlabNum($fnum){ <br/>$nums = array("0","1","2","3","4 ","5", "6","7","8","9"); <br/>$fnums = "0123456789"; <br/>for($i=0;$i<=9;$ i ) $fnum = str_replace ($nums[$i],$fnums[$i],$fnum); <br/>$fnum = ereg_replace("[^0-9.]|^0{1,}", "",$fnum) ; <br/>if($fnum=="") $fnum=0; <br/>return $fnum; <br/>//HTML-Tags entfernen <br/><? <br/>function Text2Html($txt){ <br/>$txt = str_replace(" "," ",$txt); "<","<" ,$txt); 1,}/isU"," <br/>rn",$txt); <br/>return $txt; <br/>} <br/>?> <br><br>Der Code lautet wie folgt: <br> //Relativen Pfad in absoluten Pfad konvertieren <br>< ;? <br>function relative_to_absolute($content, $feed_url) { <br>preg_match('/(http|https|ftp):///', $feed_url, $protocol); <br>$server_url = preg_replace( "/(http|https|ftp|news):///", ", $feed_url = preg_replace("//.*/ ", "", $server_url); <br> if ($server_url == '') { <br>return $content; <br>} <br>if (isset($protocol[0])) { <br>$new_content = preg_replace('/href="/ /', 'href="'.$protocol[0].$server_url.'/', $content = preg_replace('/src= "//', 'src="'.$ Protocol[0].$server_url.'/', $new_content = $content; return $new_content; <br>} <br><br>Kopieren Sie den Code wie folgt: <br>//Alle Links abrufen <br><? <br/>preg_match_all('/<as href=[ "|']?([^>"' ] )["|']?s*[^>]*>([^>] ) </a>/i',$code,$ arr); <br>return array('name'=>$arr[2],'url'=>$arr[1]); } <br>?> <br><br> Kopieren Sie den Code wie folgt: <br>/Konvertieren Sie jede Zeile der HTML-Tabelle in ein CSV-Format-Array <br><?>function get_tr_array($table ) { <br/>$table = preg_replace("'<td[ ^>]*?>'si",'"',$table); <br>$table = str_replace("</td> ",'",'$table); <br>$table = str_replace("</tr>","{tr}",$table); <br>//HTML-Tags entfernen <br>$table); = preg_replace("'<[/!]*?[^< ;>]*?>'si","",$table); <br>//Leerzeichen entfernen <br>$table = preg_replace ("'([rn])[s] '","" ,$table); <br>$table = str_replace(" ","",<br>$table = str_replace(" ", "",$table); <br>$table = explosion(" ,{tr}",$table); <br>array_pop($table); > <br><br>Kopieren Sie den Code wie folgt: <br> //Konvertieren Sie jede Zeile und Spalte der HTML-Tabelle in ein Array und sammeln Sie Tabellendaten <br><? { <br/>$table = preg_replace("'<table[^> ]*?>'si","",$table); <br>$table = preg_replace("'<tr[^> ;]*?>'si","",$table); <br>$table = preg_replace("'<td[^>]*?>'si","",$table); <br>$table = str_replace("</tr>","{ tr}",$table); <br>$table = str_replace("</td>","{td}",$table ); <br>//HTML-Tags entfernen <br>$table = preg_replace( "'<[/!]*?[^<>]*?>'si","",$table); <br>//Leerzeichen entfernen <br>$table = preg_replace("' ([rn])[s] '","",$table); <br>$table = str_replace(" ","", $table); <br>$table = str_replace(" ","",$table); <br>$table = explode('{tr}', $table); <br>array_pop($table); <br>foreach ($table as $key=>$tr) { <br>$td = explode('{td}', $tr); <br>array_pop($td); <br>$td_array[] = $td; <br>} <br>return $td_array; <br>} <br>?> <br><br>复制代码 代码如下: <br>//返回字符串中的所有单词 $distinct=true 去除重复 <br><? <br/>function split_en_str($str,$distinct=true) { <br/>preg_match_all('/([a-zA-Z]+)/',$str,$match); <br/>if ($distinct == true) { <br/>$match[1] = array_unique($match[1]); <br/>} <br/>sort($match[1]); <br/>return $match[1]; <br/>} <br/>?> <br><br>复制代码 代码如下: <br>//打印出为本PHP项目做出贡献的人员的清单 <br><? <br/>string phpcredits(void) <br/>?> <br><br><br>//获得当前的脚本网址 <br>function get_php_url(){ <br>        if(!empty($_SERVER["REQUEST_URI"])){ <br>                $scriptName = $_SERVER["REQUEST_URI"]; <br>                $nowurl = $scriptName; <br>        }else{ <br>                $scriptName = $_SERVER["PHP_SELF"]; <br>                if(empty($_SERVER["QUERY_STRING"])) $nowurl = $scriptName; <br>                else $nowurl = $scriptName."?".$_SERVER["QUERY_STRING"]; <br>        } <br>        return $nowurl; <br><br><br><br>} <br>//把全角数字转为半角数字 <br>function GetAlabNum($fnum){ <br>        $nums = array("0","1","2","3","4","5","6","7","8","9"); <br>        $fnums = "0123456789"; <br>        for($i=0;$i<=9;$i++) $fnum = str_replace($nums[$i],$fnums[$i],$fnum); <br/> $fnum = ereg_replace("[^0-9\.]|^0{1,}","",$fnum); <br/> if($fnum=="") $fnum=0; <br/> return $fnum; <br/>} <br/>//去除HTML标记 <br/>function Text2Html($txt){ <br/> $txt = str_replace(" "," ",$txt); <br/> $txt = str_replace("<","<",$txt); <br/> $txt = str_replace(">",">",$txt); <br>        $txt = preg_replace("/[\r\n]{1,}/isU","<br/>\r\n",$txt); <br>        return $txt; <br>} <br><br><br>//清除HTML标记 <br>function ClearHtml($str){ <br>        $str = str_replace('<','<',$str); <br/> $str = str_replace('>','>',$str); <br>        return $str; <br>} <br>//相对路径转化成绝对路径 <br>function relative_to_absolute($content, $feed_url) { <br>    preg_match('/(http|https|ftp):\/\//', $feed_url, $protocol); <br>    $server_url = preg_replace("/(http|https|ftp|news):\/\//", "", $feed_url); <br>    $server_url = preg_replace("/\/.*/", "", $server_url);  <br><br>    if ($server_url == '') { <br>        return $content; <br>    } <br><br><br><br>    if (isset($protocol[0])) { <br>        $new_content = preg_replace('/href="\//', 'href="'.$protocol[0].$server_url.'/', $content); <br>$new_content = preg_replace('/src="//', 'src="'.$protocol[0].$server_url.'/', $new_content} else { <br> $new_content = $); content; <br> } <br> return $new_content; <br>} //Alle Links abrufen <br>function get_all_url($code){ <br> preg_match_all('/<as href=["| ']?([^>"' ] )["|']?s*[^>]*>([^>] )</a>/i',$code,$arr) ; <br>          return array('name'=>$arr[2],'url'=>$arr[1]} <br><br><br><br><br>//Den Inhalt im angegebenen Tag abrufen <br>function get_tag_data($str, $start, $end){ <br>                                                                                               ; 🎜> $str = explosion($end, $str[1]); <br> return $str[0]; <br>} <br>//Konvertieren Sie jede Zeile der HTML-Tabelle in ein CSV-Format-Array <br>function get_tr_array($table) { <br> $table = preg_replace("'<td[^>]*?>' si",'"',$table); <br> $table = str_replace( "</td>",'",',$table); <br> $table = str_replace("</tr> ","{tr}",$table); <br> //HTML entfernen Tags <br><br><br><br><br> $table = preg_replace("'<[/!]*? [^<>]*?>'si","",$ Tabelle); ",$table); <br> $table = str_replace(" ","",$table); <br><br> $table = explosion(",{tr}",$table); <br> array_pop($table); <br>return $table); Konvertieren Sie jede Zeile der HTML-Tabelle. Konvertieren Sie jede Spalte in ein Array und sammeln Sie Tabellendaten <br>function get_td_array($table) { <br>             $table = preg_replace("'<table[^>]*?>' si","",$table ); <br> $table = preg_replace("'<tr[^>]*?>'si","",$table); <br> $table = preg_replace ("'<td[^ >]*?>'si","",$table); $table = str_replace("</tr>","{tr}",$table ); <br> $table = str_replace("</td>","{td}",$table !]*?[^< >]*?>'si","",$table); <br>                                                                                                                                            $table); <br><br><br><br><br> $table). = str_replace(" ","",$table); <br> $table = str_replace(" ","",$table ); ); <br> array_pop($table); <br> foreach ($table as $key=>$tr) { <br>                array_pop($td); <br>              )/',$str,$match); <br> if ($ unique == true) { <br>              $match[1] = array_unique($match[1]); ><br><br><br><br><br> //Dateilesefunktion <br> function PHP_Read($file_name) { <br> $fd=fopen($file_name, r); <br> while($bufline= fgets($fd, 4096)){ <br> $buf.=$bufline; <br> fclose($fd); <br> ?> 🎜><br><br><br><br><br><br>Dateischreibfunktion <br><br><br><br><br> //Dateischreibfunktion <br> function PHP_Write($ file_name,$data,$method="w") { <br> $filenum=@fopen($file_name,$method); <br> flock($ filenum,LOCK_EX); ,$data); <br> fclose($filenum); <br> return $file_data; } <br> ?> <br> // Statische Seitengenerierungsfunktion <br> function phptohtm($filefrom,$fileto,$u2u=1){ <br> if($ u2u==1){ <br> $data=PHP_Read($filefrom) ; <br> }else{ <br> $data=$filefrom; <br> PHP_Write($fileto,$data); <br> ?> ><br><br><br><br><br><br>Funktion zum Abrufen der Zustandsinformationsmenge angeben <br><br><br><br><br> //Funktion zum Abruf der Zustandsinformationsmenge angeben <br> function rec_exist($table,$where){ <br> $query="select count(*) as num from $table ".$ where; <br> $result=mysql_query($query) or die(nerror(1 )); <br> $rowcount=mysql_fetch_array($result); <br> $num=$rowcount["num"]; <br> return false; } <br> return $num; <br> } <br> ?> <br><br><br><br><br><br> Verzeichnislöschfunktion <br><br><br> // Verzeichnislöschfunktion <br> function del_DIR($directory){ <br> $mydir=dir($directory); <br> while ($file=$mydir->read()){ <br> if((is_dir ("$directory/$file")) AND ($file!=".") AND ($file!=".. ")){ <br> del_DIR("$directory/$file"); }else{ <br> if(($file!=".") AND ($file!="..")) { <br> unlink("$directory/$file"); "Verknüpfung von $directory/$file ok"; <br> } <br> } <br><br><br> $mydir->close(); <br> rmdir($directory); 🎜> //echo „rmdir $directory ok“; Erkennung der Rechtmäßigkeit des Verzeichnisnamens <br> function isen($str){ <br> $ret=""> for($i=0;$i $p=ord(substr($str,$i,1) ); <br> if(($p<48 & $p!=45 & $p!=46) | | ($p>57 & $p<65) || ($p>90 & $p<97 & $p!=95) ||. $p>122){ <br> nerror("Entspricht nicht den Spezifikationen! "); <br> } <br> $ret.=chr($p); <br> } <br> return $ret; <br> } <br> ?> <br><br><br> <br>Paging-Funktion <br><br><br>   //分页函式 <br>   function splitlist($HALT,$LRLIST,$ECHOCNT,$paper,$table,$where,$page_id,$userid){ <br>   global $splitstr,$sumcnt; <br>   if($paper=="" || $sumcnt==""){ <br>   $query = "select count(*) as num from $table $where"; <br>   $result = mysql_query($query); <br>   $row = mysql_fetch_array($result); <br>   $sumcnt=$row["num"]; <br>   if($sumcnt==0){ <br>   nerror("该版内还没有选择发布新闻 !"); <br>    } <br>   $paper=1; <br>    } <br><br><br>   $sumpaper=($sumcnt-$sumcnt%$ECHOCNT)/$ECHOCNT; <br>   if(($sumcnt%$ECHOCNT)!=0) $sumpaper =1; <br>   if($sumpaper==1 && $HALT==0) return($where); <br>   $enwhere=base64_encode(base64_encode($where)); <br>   if(($LRLIST*2 1) < $sumpaper){ <br/>   if(($paper-$LRLIST) < 2){ <br/>   $tract=1; <br/>   $sub=$LRLIST*2 1; <br/>    }else if(($paper $LRLIST) >= $sumpaper){ <br>   $tract=$sumpaper-($LRLIST*2); <br>   $sub=$sumpaper; <br>    }else{ <br>   $tract=$paper-$LRLIST; <br>   $sub=$paper $LRLIST; <br>    } <br>    }else{ <br>   $tract=1; <br>   $sub=$sumpaper; <br>    } <br>   $uppaper=$paper-1; <br>   $downpaper=$paper 1; <br>   $startcnt=($paper-1)*$ECHOCNT; <br>   $where.=" limit ${ startcnt },${ ECHOCNT }"; <br><br><br><br>   if($tract > 1) { $splitstr="【 << "; } <br/>   else $splitstr="【 << "; <br/>   for($i=$tract;$i<=$sub;$i ){ <br/>   if ($i!=$paper) $splitstr.="".$i." "; <br/>   else $splitstr.="".$i." "; <br/>    } <br/>   if ($sub!=$sumpaper) $splitstr.=">> 】"; <br>   else $splitstr.=">> 】"; <br>   return($where); <br>    } <br>   ?> <br><br><br><br>关于分页函式的使用说明  <br>      /* <br>   #### 检索分页函式 #### <br>   Int $HALT - 检索结果仅分1页时是否(1/0)显示页码条 <br>   Int $LRLIST - (页码条显示页码数-1)/2 <br>   Int $ECHOCNT - 检索时每页显示记录的数量 <br>   Int $ paper - Beispiel: $paper=$HTTP_GET_VARS[paper]; <br>   Varchar $table – Beispiel: $table="db.table"; <br>   Varchar $where - Beispiel: $where="where field='value'"; <br>  行函式后在相应的位置执行 echo $splitstr; <br>   <br>   函式调用前需获取变量 - <br>   $paper=$HTTP_GET_VARS[paper]; <br>   $sumcnt=$HTTP_GET_VARS[sumcnt]; <br>   $enwhere=$HTTP_GET_VARS[enwhere]; <br>   <br>   Return (Varchar $where) - 分页后检索语句的检索条件  Fehler); <br>   */ <br><br><br><br><br>图片文件上传函式 <br><br><br><br><br>//图片文件上传函式 <br> function upload_img($UploadFile,$UploadFile_name,$UploadFile_size,$UploadPath,$max_size=64){ <br>   <br>   //$TimeLimit=60; //设置超时限制时间 缺省时间为 30秒 设置为0时为不限时 <br>   //set_time_limit($TimeLimit); <br>   if(($UploadFile!= "none" )&&($UploadFile != "" )){ <br>   $FileName=$UploadPath.$UploadFile_name; <br>   if($UploadFile_size <1024){ <br/>   $FileSize="(string)$UploadFile_size" . „字节“; <br/>    }elseif($UploadFile_size <(1024 * $max_size)){ <br/><br/><br/><br/>   $FileSize=number_format((double)($UploadFile_size / 1024), 1) . „KB“; <br/>    }else{ <br/>nerror("Datei überschreitet Größenbeschränkung!"); <br/> } <br/> //{ <br/> //$FileSize="number_format((double)($UploadFile_size" / (1024 * 1024)), 1) . " MB"; <br/> // } <br/> if(!file_exists($FileName)){ <br/> if(copy($UploadFile,$FileName)){ <br/> return "$UploadFile_name ($FileSize)" ; <br/> }else{ <br/> nerror("Datei $UploadFile_name fehlgeschlagen!"); Existiert bereits! So ermitteln Sie die Legitimität einer IP-Adresse <br/>if(!strcmp(long2ip(sprintf("%u",ip2long($ip))),$ip)) echo "is ipn"--- - <br/><br/>Regelmäßige Beurteilung von E-Mails <br/>eregi("^[_.0-9a-zA-Z-] @([0-9a-zA-Z][0-9a-zA-Z_- ] .) [a-zA-Z]$", $email); <br/><br/><br/><br/>Beispiel für die Überprüfung, ob die IP-Adresse und die Maske zulässig sind <br/><br/><br/><br/><br/> <br/>$ip = '192.168.0.84'; <br/>$mask = '255.255.255.0'; <br/>$ip = ip2long($ ip); <br/>$mask = ip2long($mask); <br/>$network = ip2long($network); <br/><br/>if( ($ip & $mask) == $network) echo "valid ip und maskn"; <br/>?> <br><br><br><br>---- <br><br><br><br>So legen Sie die Ausgabe des Datei-Download-Headers fest <br> <br><br><br><br><br>header("Content-type: application/x-download"); <br>header("Content-Disposition: attachment; filename=$file_download_name;"); <br>header( "Accept-Ranges: Bytes"); <br>header("Content-Length: $download_size"); <br>echo 'xxx' <br><br><br><br>Header verwenden um die FTP-Download-Methode auszugeben, Und unterstützt die Wiederaufnahme des Haltepunkts <br><br><br><br><br>header('Pragma: public'); privat'); <br>header('Cache-Control: no-cache, must-revalidate'); <br>header('Connection: close'); <br>header ("Content-Type: audio/mpeg"); <br>header("Location:ftp://download:1bk3l4s3k9s2@232.2.22.22/2222/web Technology Development Knowledge Base/cn_web.rmvb"); <br><br><br><br><br><br><br><br>Reguläre Übereinstimmung Chinesisch <br>ereg("^[".chr(0xa1)."-".chr(0xff) ."] $ ", $str); <br><br>Batch-Ersetzen von Hyperlinks im Text <br><br><br><br><br><br><?php <br/>function urlParse($ str = ''){ <br/> if ('' == $str) return $str; replace = <<<EOPHP <br/> '<a href="'.htmlentities('1').htmlentities('2').'">'.htmlentities('1').htmlentities( '2 ').'</a>' <br>EOPHP; type) = every($types)){ <br> $ret = preg_replace("|($type://)([^s]*)|ie ", $replace, $ret); <br> <br><br><br>return $ret; <br>} <br>?><br></p> </div> </div> <div class="wzconShengming_sp"> <div class="bzsmdiv_sp">Erklärung dieser Website</div> <div>Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn</div> </div> </div> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5902227090019525" data-ad-slot="2507867629"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <div class="AI_ToolDetails_main4sR"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5902227090019525" data-ad-slot="3653428331" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <!-- <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>Heißer Artikel</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/1796780570.html" title="R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>1 Monate vor</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/1796780641.html" title="R.E.P.O. Beste grafische Einstellungen" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O. Beste grafische Einstellungen</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>1 Monate vor</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/1796785841.html" title="Assassin's Creed Shadows: Seashell Riddle -Lösung" class="phpgenera_Details_mainR4_bottom_title">Assassin's Creed Shadows: Seashell Riddle -Lösung</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3 Wochen vor</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/1796789525.html" title="Was ist neu in Windows 11 KB5054979 und wie Sie Update -Probleme beheben" class="phpgenera_Details_mainR4_bottom_title">Was ist neu in Windows 11 KB5054979 und wie Sie Update -Probleme beheben</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>2 Wochen vor</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/1796780618.html" title="Will R.E.P.O. Crossplay haben?" class="phpgenera_Details_mainR4_bottom_title">Will R.E.P.O. Crossplay haben?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>1 Monate vor</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/de/article.html">Mehr anzeigen</a> </div> </div> </div> --> <div class="phpgenera_Details_mainR3"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hottools2.png" alt="" /> <h2>Heiße KI -Werkzeuge</h2> </div> <div class="phpgenera_Details_mainR3_bottom"> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/de/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411540686492.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undresser.AI Undress" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/de/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_title"> <h3>Undresser.AI Undress</h3> </a> <p>KI-gestützte App zum Erstellen realistischer Aktfotos</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/de/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411552797167.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="AI Clothes Remover" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/de/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_title"> <h3>AI Clothes Remover</h3> </a> <p>Online-KI-Tool zum Entfernen von Kleidung aus Fotos.</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/de/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173410641626608.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undress AI Tool" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/de/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_title"> <h3>Undress AI Tool</h3> </a> <p>Ausziehbilder kostenlos</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/de/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411529149311.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Clothoff.io" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/de/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_title"> <h3>Clothoff.io</h3> </a> <p>KI-Kleiderentferner</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/de/ai/ai-hentai-generator" title="AI Hentai Generator" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173405034393877.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="AI Hentai Generator" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/de/ai/ai-hentai-generator" title="AI Hentai Generator" class="phpmain_tab2_mids_title"> <h3>AI Hentai Generator</h3> </a> <p>Erstellen Sie kostenlos Ai Hentai.</p> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/de/ai">Mehr anzeigen</a> </div> </div> </div> <script src="https://sw.php.cn/hezuo/cac1399ab368127f9b113b14eb3316d0.js" type="text/javascript"></script> <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>Heißer Artikel</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/1796780570.html" title="R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>1 Monate vor</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/1796780641.html" title="R.E.P.O. Beste grafische Einstellungen" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O. Beste grafische Einstellungen</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>1 Monate vor</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/1796785841.html" title="Assassin's Creed Shadows: Seashell Riddle -Lösung" class="phpgenera_Details_mainR4_bottom_title">Assassin's Creed Shadows: Seashell Riddle -Lösung</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3 Wochen vor</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/1796789525.html" title="Was ist neu in Windows 11 KB5054979 und wie Sie Update -Probleme beheben" class="phpgenera_Details_mainR4_bottom_title">Was ist neu in Windows 11 KB5054979 und wie Sie Update -Probleme beheben</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>2 Wochen vor</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/1796780618.html" title="Will R.E.P.O. Crossplay haben?" class="phpgenera_Details_mainR4_bottom_title">Will R.E.P.O. Crossplay haben?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>1 Monate vor</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/de/article.html">Mehr anzeigen</a> </div> </div> </div> <div class="phpgenera_Details_mainR3"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hottools2.png" alt="" /> <h2>Heiße Werkzeuge</h2> </div> <div class="phpgenera_Details_mainR3_bottom"> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/de/toolset/development-tools/92" title="Notepad++7.3.1" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab96f0f39f7357.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="Notepad++7.3.1" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/de/toolset/development-tools/92" title="Notepad++7.3.1" class="phpmain_tab2_mids_title"> <h3>Notepad++7.3.1</h3> </a> <p>Einfach zu bedienender und kostenloser Code-Editor</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/de/toolset/development-tools/93" title="SublimeText3 chinesische Version" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab97a3baad9677.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3 chinesische Version" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/de/toolset/development-tools/93" title="SublimeText3 chinesische Version" class="phpmain_tab2_mids_title"> <h3>SublimeText3 chinesische Version</h3> </a> <p>Chinesische Version, sehr einfach zu bedienen</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/de/toolset/development-tools/121" title="Senden Sie Studio 13.0.1" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab97ecd1ab2670.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="Senden Sie Studio 13.0.1" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/de/toolset/development-tools/121" title="Senden Sie Studio 13.0.1" class="phpmain_tab2_mids_title"> <h3>Senden Sie Studio 13.0.1</h3> </a> <p>Leistungsstarke integrierte PHP-Entwicklungsumgebung</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/de/toolset/development-tools/469" title="Dreamweaver CS6" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58d0e0fc74683535.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="Dreamweaver CS6" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/de/toolset/development-tools/469" title="Dreamweaver CS6" class="phpmain_tab2_mids_title"> <h3>Dreamweaver CS6</h3> </a> <p>Visuelle Webentwicklungstools</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/de/toolset/development-tools/500" title="SublimeText3 Mac-Version" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58d34035e2757995.png?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3 Mac-Version" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/de/toolset/development-tools/500" title="SublimeText3 Mac-Version" class="phpmain_tab2_mids_title"> <h3>SublimeText3 Mac-Version</h3> </a> <p>Codebearbeitungssoftware auf Gottesniveau (SublimeText3)</p> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/de/ai">Mehr anzeigen</a> </div> </div> </div> <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>Heiße Themen</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/gmailyxdlrkzn" title="Wo ist der Login-Zugang für Gmail-E-Mail?" class="phpgenera_Details_mainR4_bottom_title">Wo ist der Login-Zugang für Gmail-E-Mail?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>7554</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>15</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/cakephp-tutor" title="CakePHP-Tutorial" class="phpgenera_Details_mainR4_bottom_title">CakePHP-Tutorial</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1382</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>52</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/steamdzhmcssmgs" title="Wie lautet das Format des Kontonamens von Steam?" class="phpgenera_Details_mainR4_bottom_title">Wie lautet das Format des Kontonamens von Steam?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>83</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>11</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/winactivationkeyper" title="Win11 -Aktivierungsschlüssel dauerhaft" class="phpgenera_Details_mainR4_bottom_title">Win11 -Aktivierungsschlüssel dauerhaft</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>59</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>19</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/de/faq/newyorktimesdailybrief" title="NYT -Verbindungen Hinweise und Antworten" class="phpgenera_Details_mainR4_bottom_title">NYT -Verbindungen Hinweise und Antworten</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>28</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>96</span> </div> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/de/faq/zt">Mehr anzeigen</a> </div> </div> </div> </div> </div> <div class="Article_Details_main2"> <div class="phpgenera_Details_mainL4"> <div class="phpmain1_2_top"> <a href="javascript:void(0);" class="phpmain1_2_top_title">Related knowledge<img src="/static/imghw/index2_title2.png" alt="" /></a> </div> <div class="phpgenera_Details_mainL4_info"> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/de/faq/1796787277.html" title="Alipay PHP SDK -Übertragungsfehler: Wie kann das Problem von 'Class Signdata nicht deklarieren' gelöst werden?" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/246/273/174303625625009.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Alipay PHP SDK -Übertragungsfehler: Wie kann das Problem von 'Class Signdata nicht deklarieren' gelöst werden?" /> </a> <a href="https://www.php.cn/de/faq/1796787277.html" title="Alipay PHP SDK -Übertragungsfehler: Wie kann das Problem von 'Class Signdata nicht deklarieren' gelöst werden?" class="phphistorical_Version2_mids_title">Alipay PHP SDK -Übertragungsfehler: Wie kann das Problem von 'Class Signdata nicht deklarieren' gelöst werden?</a> <span class="Articlelist_txts_time">Apr 01, 2025 am 07:21 AM</span> <p class="Articlelist_txts_p">Alipay PHP ...</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/de/faq/1796790404.html" title="Erklären Sie JSON Web Tokens (JWT) und ihren Anwendungsfall in PHP -APIs." class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/253/068/174378264165720.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Erklären Sie JSON Web Tokens (JWT) und ihren Anwendungsfall in PHP -APIs." /> </a> <a href="https://www.php.cn/de/faq/1796790404.html" title="Erklären Sie JSON Web Tokens (JWT) und ihren Anwendungsfall in PHP -APIs." class="phphistorical_Version2_mids_title">Erklären Sie JSON Web Tokens (JWT) und ihren Anwendungsfall in PHP -APIs.</a> <span class="Articlelist_txts_time">Apr 05, 2025 am 12:04 AM</span> <p class="Articlelist_txts_p">JWT ist ein offener Standard, der auf JSON basiert und zur sicheren Übertragung von Informationen zwischen Parteien verwendet wird, hauptsächlich für die Identitätsauthentifizierung und den Informationsaustausch. 1. JWT besteht aus drei Teilen: Header, Nutzlast und Signatur. 2. Das Arbeitsprinzip von JWT enthält drei Schritte: Generierung von JWT, Überprüfung von JWT und Parsingnayload. 3. Bei Verwendung von JWT zur Authentifizierung in PHP kann JWT generiert und überprüft werden, und die Funktionen und Berechtigungsinformationen der Benutzer können in die erweiterte Verwendung aufgenommen werden. 4. Häufige Fehler sind Signaturüberprüfungsfehler, Token -Ablauf und übergroße Nutzlast. Zu Debugging -Fähigkeiten gehört die Verwendung von Debugging -Tools und Protokollierung. 5. Leistungsoptimierung und Best Practices umfassen die Verwendung geeigneter Signaturalgorithmen, das Einstellen von Gültigkeitsperioden angemessen.</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/de/faq/1796788900.html" title="Beschreiben Sie die soliden Prinzipien und wie sie sich für die PHP -Entwicklung anwenden." class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/253/068/174360984159295.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Beschreiben Sie die soliden Prinzipien und wie sie sich für die PHP -Entwicklung anwenden." /> </a> <a href="https://www.php.cn/de/faq/1796788900.html" title="Beschreiben Sie die soliden Prinzipien und wie sie sich für die PHP -Entwicklung anwenden." class="phphistorical_Version2_mids_title">Beschreiben Sie die soliden Prinzipien und wie sie sich für die PHP -Entwicklung anwenden.</a> <span class="Articlelist_txts_time">Apr 03, 2025 am 12:04 AM</span> <p class="Articlelist_txts_p">Die Anwendung des soliden Prinzips in der PHP -Entwicklung umfasst: 1. Prinzip der Einzelverantwortung (SRP): Jede Klasse ist nur für eine Funktion verantwortlich. 2. Open and Close Principle (OCP): Änderungen werden eher durch Erweiterung als durch Modifikation erreicht. 3.. Lischs Substitutionsprinzip (LSP): Unterklassen können Basisklassen ersetzen, ohne die Programmgenauigkeit zu beeinträchtigen. 4. Schnittstellen-Isolationsprinzip (ISP): Verwenden Sie feinkörnige Schnittstellen, um Abhängigkeiten und nicht verwendete Methoden zu vermeiden. 5. Abhängigkeitsinversionsprinzip (DIP): Hoch- und niedrige Module beruhen auf der Abstraktion und werden durch Abhängigkeitsinjektion implementiert.</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/de/faq/1796782794.html" title="Erklären Sie das Konzept der späten statischen Bindung in PHP." class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202503/21/2025032113332596253.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Erklären Sie das Konzept der späten statischen Bindung in PHP." /> </a> <a href="https://www.php.cn/de/faq/1796782794.html" title="Erklären Sie das Konzept der späten statischen Bindung in PHP." class="phphistorical_Version2_mids_title">Erklären Sie das Konzept der späten statischen Bindung in PHP.</a> <span class="Articlelist_txts_time">Mar 21, 2025 pm 01:33 PM</span> <p class="Articlelist_txts_p">In Artikel wird die in PHP 5.3 eingeführte LSB -Bindung (LSB) erörtert, die die Laufzeitauflösung der statischen Methode ermöglicht, um eine flexiblere Vererbung zu erfordern. Die praktischen Anwendungen und potenziellen Perfo von LSB</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/de/faq/1796786988.html" title="Wie setze ich nach dem Neustart des Systems automatisch Berechtigungen von Unixsocket fest?" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/246/273/174304058392432.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Wie setze ich nach dem Neustart des Systems automatisch Berechtigungen von Unixsocket fest?" /> </a> <a href="https://www.php.cn/de/faq/1796786988.html" title="Wie setze ich nach dem Neustart des Systems automatisch Berechtigungen von Unixsocket fest?" class="phphistorical_Version2_mids_title">Wie setze ich nach dem Neustart des Systems automatisch Berechtigungen von Unixsocket fest?</a> <span class="Articlelist_txts_time">Mar 31, 2025 pm 11:54 PM</span> <p class="Articlelist_txts_p">So setzen Sie die Berechtigungen von Unixsocket automatisch nach dem Neustart des Systems. Jedes Mal, wenn das System neu startet, müssen wir den folgenden Befehl ausführen, um die Berechtigungen von Unixsocket: sudo ...</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/de/faq/1796787536.html" title="Wie sende ich eine Postanforderung mit JSON -Daten mithilfe der Curl -Bibliothek von PHP?" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/246/273/174269580466138.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Wie sende ich eine Postanforderung mit JSON -Daten mithilfe der Curl -Bibliothek von PHP?" /> </a> <a href="https://www.php.cn/de/faq/1796787536.html" title="Wie sende ich eine Postanforderung mit JSON -Daten mithilfe der Curl -Bibliothek von PHP?" class="phphistorical_Version2_mids_title">Wie sende ich eine Postanforderung mit JSON -Daten mithilfe der Curl -Bibliothek von PHP?</a> <span class="Articlelist_txts_time">Apr 01, 2025 pm 03:12 PM</span> <p class="Articlelist_txts_p">Senden von JSON -Daten mithilfe der Curl -Bibliothek von PHP in der PHP -Entwicklung müssen häufig mit externen APIs interagieren. Eine der gängigen Möglichkeiten besteht darin, die Curl Library zu verwenden, um Post � ...</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/de/faq/1796786130.html" title="Rahmensicherheitsmerkmale: Schutz vor Schwachstellen." class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202503/28/2025032817115475121.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Rahmensicherheitsmerkmale: Schutz vor Schwachstellen." /> </a> <a href="https://www.php.cn/de/faq/1796786130.html" title="Rahmensicherheitsmerkmale: Schutz vor Schwachstellen." class="phphistorical_Version2_mids_title">Rahmensicherheitsmerkmale: Schutz vor Schwachstellen.</a> <span class="Articlelist_txts_time">Mar 28, 2025 pm 05:11 PM</span> <p class="Articlelist_txts_p">In Artikel werden wichtige Sicherheitsfunktionen in Frameworks erörtert, um vor Schwachstellen zu schützen, einschließlich Eingabevalidierung, Authentifizierung und regelmäßigen Aktualisierungen.</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/de/faq/1796786131.html" title="Anpassung/Erweiterung von Frameworks: So fügen Sie benutzerdefinierte Funktionen hinzu." class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202503/28/2025032817124947598.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Anpassung/Erweiterung von Frameworks: So fügen Sie benutzerdefinierte Funktionen hinzu." /> </a> <a href="https://www.php.cn/de/faq/1796786131.html" title="Anpassung/Erweiterung von Frameworks: So fügen Sie benutzerdefinierte Funktionen hinzu." class="phphistorical_Version2_mids_title">Anpassung/Erweiterung von Frameworks: So fügen Sie benutzerdefinierte Funktionen hinzu.</a> <span class="Articlelist_txts_time">Mar 28, 2025 pm 05:12 PM</span> <p class="Articlelist_txts_p">In dem Artikel werden Frameworks hinzugefügt, das sich auf das Verständnis der Architektur, das Identifizieren von Erweiterungspunkten und Best Practices für die Integration und Debuggierung hinzufügen.</p> </div> </div> <a href="https://www.php.cn/de/be/" class="phpgenera_Details_mainL4_botton"> <span>See all articles</span> <img src="/static/imghw/down_right.png" alt="" /> </a> </div> </div> </div> </main> <footer> <div class="footer"> <div class="footertop"> <img src="/static/imghw/logo.png" alt=""> <p>Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!</p> </div> <div class="footermid"> <a href="https://www.php.cn/de/about/us.html">Über uns</a> <a href="https://www.php.cn/de/about/disclaimer.html">Haftungsausschluss</a> <a href="https://www.php.cn/de/update/article_0_1.html">Sitemap</a> </div> <div class="footerbottom"> <p> © php.cn All rights reserved </p> </div> </div> </footer> <input type="hidden" id="verifycode" value="/captcha.html"> <script>layui.use(['element', 'carousel'], function () {var element = layui.element;$ = layui.jquery;var carousel = layui.carousel;carousel.render({elem: '#test1', width: '100%', height: '330px', arrow: 'always'});$.getScript('/static/js/jquery.lazyload.min.js', function () {$("img").lazyload({placeholder: "/static/images/load.jpg", effect: "fadeIn", threshold: 200, skip_invisible: false});});});</script> <script src="/static/js/common_new.js"></script> <script type="text/javascript" src="/static/js/jquery.cookie.js?1744959535"></script> <script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script> <link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css?2' type='text/css' media='all' /> <script type='text/javascript' src='/static/js/viewer.min.js?1'></script> <script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script> <script type="text/javascript" src="/static/js/global.min.js?5.5.53"></script> <script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function () { var u = "https://tongji.php.cn/"; _paq.push(['setTrackerUrl', u + 'matomo.php']); _paq.push(['setSiteId', '9']); var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s); })(); </script> <script> // top layui.use(function () { var util = layui.util; util.fixbar({ on: { mouseenter: function (type) { layer.tips(type, this, { tips: 4, fixed: true, }); }, mouseleave: function (type) { layer.closeAll("tips"); }, }, }); }); document.addEventListener("DOMContentLoaded", (event) => { // 定义一个函数来处理滚动链接的点击事件 function setupScrollLink(scrollLinkId, targetElementId) { const scrollLink = document.getElementById(scrollLinkId); const targetElement = document.getElementById(targetElementId); if (scrollLink && targetElement) { scrollLink.addEventListener("click", (e) => { e.preventDefault(); // 阻止默认链接行为 targetElement.scrollIntoView({ behavior: "smooth" }); // 平滑滚动到目标元素 }); } else { console.warn( `Either scroll link with ID '${scrollLinkId}' or target element with ID '${targetElementId}' not found.` ); } } // 使用该函数设置多个滚动链接 setupScrollLink("Article_Details_main1L2s_1", "article_main_title1"); setupScrollLink("Article_Details_main1L2s_2", "article_main_title2"); setupScrollLink("Article_Details_main1L2s_3", "article_main_title3"); setupScrollLink("Article_Details_main1L2s_4", "article_main_title4"); setupScrollLink("Article_Details_main1L2s_5", "article_main_title5"); setupScrollLink("Article_Details_main1L2s_6", "article_main_title6"); // 可以继续添加更多的滚动链接设置 }); window.addEventListener("scroll", function () { var fixedElement = document.getElementById("Article_Details_main1Lmain"); var scrollTop = window.scrollY || document.documentElement.scrollTop; // 兼容不同浏览器 var clientHeight = window.innerHeight || document.documentElement.clientHeight; // 视口高度 var scrollHeight = document.documentElement.scrollHeight; // 页面总高度 // 计算距离底部的距离 var distanceToBottom = scrollHeight - scrollTop - clientHeight; // 当距离底部小于或等于300px时,取消固定定位 if (distanceToBottom <= 980) { fixedElement.classList.remove("Article_Details_main1Lmain"); fixedElement.classList.add("Article_Details_main1Lmain_relative"); } else { // 否则,保持固定定位 fixedElement.classList.remove("Article_Details_main1Lmain_relative"); fixedElement.classList.add("Article_Details_main1Lmain"); } }); </script> </body> </html>