国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Backend Development PHP Tutorial A beautiful php verification code class (share)_PHP tutorial

A beautiful php verification code class (share)_PHP tutorial

Jul 21, 2016 pm 02:59 PM
class php code share copy verify

Directly upload the code:

Copy code The code is as follows:

//Verification code class
class ValidateCode {
private $charset = 'abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789';//Random factor
private $code;//Verification code
private $codelen = 4;//Verification code length
private $width = 130;//Width
private $height = 50;//Height
private $img;//Graphic resource handle
private $font;//Specified font
private $fontsize = 20;//Specified font size
private $fontcolor;//Specify font color
//Constructor initialization
public function __construct() {
$this->font = dirname(__FILE__).'/font/elephant.ttf ';//Please note that the font path must be written correctly, otherwise the picture cannot be displayed
}
//Generate random code
private function createCode() {
$_len = strlen($this->charset )-1;
for ($i=0;$i<$this->codelen;$i++) {
$this->code .= $this->charset[mt_rand(0, $_len)];
}
}
//Generate background
private function createBg() {
$this->img = imagecreatetruecolor($this->width, $this ->height);
$color = imagecolorallocate($this->img, mt_rand(157,255), mt_rand(157,255), mt_rand(157,255));
imagefilledrectangle($this->img,0 ,$this->height,$this->width,0,$color);
}
//Generate text
private function createFont() {
$_x = $this- >width / $this->codelen;
for ($i=0;$i<$this->codelen;$i++) {
$this->fontcolor = imagecolorallocate($this- >img,mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));
imagettftext($this->img,$this->fontsize,mt_rand(-30,30),$_x* $i+mt_rand(1,5),$this->height / 1.4,$this->fontcolor,$this->font,$this->code[$i]);
}
}
//Generate lines and snowflakes
private function createLine() {
//Line
for ($i=0;$i<6;$i++) {
$ color = imagecolorallocate($this->img,mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));
imageline($this->img,mt_rand(0,$this->width) ,mt_rand(0,$this->height),mt_rand(0,$this->width),mt_rand(0,$this->height),$color);
}
// Snowflake
for ($i=0;$i<100;$i++) {
$color = imagecolorallocate($this->img,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255)) ;
imagestring($this->img,mt_rand(1,5),mt_rand(0,$this->width),mt_rand(0,$this->height),'*',$color );
}
}
//Output
private function outPut() {
header('Content-type:image/png');
imagepng($this-> ;img);
imagedestroy($this->img);
}
//Generate externally
public function doimg() {
$this->createBg();
$this->createCode();
$this->createLine();
$this->createFont();
$this->outPut();
}
//Get verification code
public function getCode() {
return strtolower($this->code);
}
}

Output Example:

Usage:
1. First save the verification code class as a file named ValidateCode.class.php;
2. Create a new file named captcha.php file to call this class;
captcha.php

Copy the code The code is as follows:

session_start();
require './ValidateCode.class.php'; //Include the class first, and modify the actual path according to the actual situation.
$_vc = new ValidateCode(); //Instantiate an object
$_vc->doimg();
$_SESSION['authnum_session'] = $_vc->getCode();/ /Save the verification code in SESSION

3. Quote it into the page, the code is as follows:
Copy the code The code is as follows:



4. A complete verification page, the code is as follows:
Copy the code The code is as follows:

session_start();
//On the page, you must first open the session,
//error_reporting(2047);
session_destroy();
//Remove the session so that it can be retrieved every time New session value;
//Using seesion works well and is very convenient
?>


session image verification example< ;/title><br><style type="text/css"><br>#login p{<br>margin-top: 15px;<br>line-height: 20px;<br>font-size : 14px;<br>font-weight: bold;<br>}<br>#login img{<br>cursor:pointer;<br>}<br>form{<br>margin-left:20px;<br>}<br></style><br></head> <br><body> <p><form id="login" action="" method="post"><br><p>This example is a session verification instance</p><br><p><br> <span>Verification code:</span><br><input type="text" name="validate" value="" size=10> <br><img title="Click to refresh" src= "./captcha.php" align="absbottom" onclick="this.src='captcha.php?'+Math.random();"></img><br></p><br><p><br><input type="submit"><br></p><br></form><br><?php<BR>//Print the previous session ;<BR>//echo "Previous session:<b>".$_SESSION["authnum_session"]."</b><br>";<br>$validate="";<br> if(isset($_POST["validate"])){<br>$validate=$_POST["validate"];<br>echo "What you just entered is: ".$_POST["validate"]." <br>Status: ";<br>if($validate!=$_SESSION["authnum_session"]){<br>//Determine whether the session value is consistent with the verification code entered by the user;<br>echo "< font color=red>Incorrect input</font>"; <br>}else{<br>echo "<font color=green>Passed verification</font>"; <br>}<br>} <br>?><br></p> </div> <br><strong>Full demo download: demo</strong> <p align="left"></p> <div style="display:none;"> <span id="url" itemprop="url">http://www.bkjia.com/PHPjc/328147.html</span><span id="indexUrl" itemprop="indexUrl">www.bkjia.com</span><span id="isOriginal" itemprop="isOriginal">true</span><span id="isBasedOnUrl" itemprop="isBasedOnUrl">http: //www.bkjia.com/PHPjc/328147.html</span><span id="genre" itemprop="genre">TechArticle</span><span id="description" itemprop="description">Directly upload the code: Copy the code as follows: //Verification code class class ValidateCode { private $charset = 'abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789' ;//Random factor private $code;...</span> </div> <div id="377j5v51b" class="art_confoot"></div> </div> </div> <div id="377j5v51b" class="wzconShengming_sp"> <div id="377j5v51b" class="bzsmdiv_sp">Statement of this Website</div> <div>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</div> </div> </div> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5902227090019525" data-ad-slot="2507867629"></ins> <div id="377j5v51b" 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> <!-- <div id="377j5v51b" class="phpgenera_Details_mainR4"> <div id="377j5v51b" class="phpmain1_4R_readrank"> <div id="377j5v51b" 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>Hot Article</h2> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottom"> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/1796821119.html" title="Guide: Stellar Blade Save File Location/Save File Lost/Not Saving" class="phpgenera_Details_mainR4_bottom_title">Guide: Stellar Blade Save File Location/Save File Lost/Not Saving</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <span>4 weeks ago</span> <span>By DDD</span> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/1796827210.html" title="Oguri Cap Build Guide | A Pretty Derby Musume" class="phpgenera_Details_mainR4_bottom_title">Oguri Cap Build Guide | A Pretty Derby Musume</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <span>2 weeks ago</span> <span>By Jack chen</span> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/1796828723.html" title="Agnes Tachyon Build Guide | A Pretty Derby Musume" class="phpgenera_Details_mainR4_bottom_title">Agnes Tachyon Build Guide | A Pretty Derby Musume</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <span>1 weeks ago</span> <span>By Jack chen</span> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/1796821436.html" title="Dune: Awakening - Advanced Planetologist Quest Walkthrough" class="phpgenera_Details_mainR4_bottom_title">Dune: Awakening - Advanced Planetologist Quest Walkthrough</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <span>3 weeks ago</span> <span>By Jack chen</span> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/1796821278.html" title="Date Everything: Dirk And Harper Relationship Guide" class="phpgenera_Details_mainR4_bottom_title">Date Everything: Dirk And Harper Relationship Guide</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <span>4 weeks ago</span> <span>By Jack chen</span> </div> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR3_more"> <a href="http://www.miracleart.cn/article.html">Show More</a> </div> </div> </div> --> <div id="377j5v51b" class="phpgenera_Details_mainR3"> <div id="377j5v51b" class="phpmain1_4R_readrank"> <div id="377j5v51b" 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>Hot AI Tools</h2> </div> <div id="377j5v51b" class="phpgenera_Details_mainR3_bottom"> <div id="377j5v51b" class="phpmain_tab2_mids_top"> <a href="http://www.miracleart.cn/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 id="377j5v51b" class="phpmain_tab2_mids_info"> <a href="http://www.miracleart.cn/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_title"> <h3>Undress AI Tool</h3> </a> <p>Undress images for free</p> </div> </div> <div id="377j5v51b" class="phpmain_tab2_mids_top"> <a href="http://www.miracleart.cn/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 id="377j5v51b" class="phpmain_tab2_mids_info"> <a href="http://www.miracleart.cn/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_title"> <h3>Undresser.AI Undress</h3> </a> <p>AI-powered app for creating realistic nude photos</p> </div> </div> <div id="377j5v51b" class="phpmain_tab2_mids_top"> <a href="http://www.miracleart.cn/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 id="377j5v51b" class="phpmain_tab2_mids_info"> <a href="http://www.miracleart.cn/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_title"> <h3>AI Clothes Remover</h3> </a> <p>Online AI tool for removing clothes from photos.</p> </div> </div> <div id="377j5v51b" class="phpmain_tab2_mids_top"> <a href="http://www.miracleart.cn/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 id="377j5v51b" class="phpmain_tab2_mids_info"> <a href="http://www.miracleart.cn/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_title"> <h3>Clothoff.io</h3> </a> <p>AI clothes remover</p> </div> </div> <div id="377j5v51b" class="phpmain_tab2_mids_top"> <a href="http://www.miracleart.cn/ai/video-swap" title="Video Face Swap" 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/173414504068133.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Video Face Swap" /> </a> <div id="377j5v51b" class="phpmain_tab2_mids_info"> <a href="http://www.miracleart.cn/ai/video-swap" title="Video Face Swap" class="phpmain_tab2_mids_title"> <h3>Video Face Swap</h3> </a> <p>Swap faces in any video effortlessly with our completely free AI face swap tool!</p> </div> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR3_more"> <a href="http://www.miracleart.cn/ai">Show More</a> </div> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4"> <div id="377j5v51b" class="phpmain1_4R_readrank"> <div id="377j5v51b" 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>Hot Article</h2> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottom"> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/1796821119.html" title="Guide: Stellar Blade Save File Location/Save File Lost/Not Saving" class="phpgenera_Details_mainR4_bottom_title">Guide: Stellar Blade Save File Location/Save File Lost/Not Saving</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <span>4 weeks ago</span> <span>By DDD</span> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/1796827210.html" title="Oguri Cap Build Guide | A Pretty Derby Musume" class="phpgenera_Details_mainR4_bottom_title">Oguri Cap Build Guide | A Pretty Derby Musume</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <span>2 weeks ago</span> <span>By Jack chen</span> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/1796828723.html" title="Agnes Tachyon Build Guide | A Pretty Derby Musume" class="phpgenera_Details_mainR4_bottom_title">Agnes Tachyon Build Guide | A Pretty Derby Musume</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <span>1 weeks ago</span> <span>By Jack chen</span> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/1796821436.html" title="Dune: Awakening - Advanced Planetologist Quest Walkthrough" class="phpgenera_Details_mainR4_bottom_title">Dune: Awakening - Advanced Planetologist Quest Walkthrough</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <span>3 weeks ago</span> <span>By Jack chen</span> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/1796821278.html" title="Date Everything: Dirk And Harper Relationship Guide" class="phpgenera_Details_mainR4_bottom_title">Date Everything: Dirk And Harper Relationship Guide</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <span>4 weeks ago</span> <span>By Jack chen</span> </div> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR3_more"> <a href="http://www.miracleart.cn/article.html">Show More</a> </div> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR3"> <div id="377j5v51b" class="phpmain1_4R_readrank"> <div id="377j5v51b" 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>Hot Tools</h2> </div> <div id="377j5v51b" class="phpgenera_Details_mainR3_bottom"> <div id="377j5v51b" class="phpmain_tab2_mids_top"> <a href="http://www.miracleart.cn/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 id="377j5v51b" class="phpmain_tab2_mids_info"> <a href="http://www.miracleart.cn/toolset/development-tools/92" title="Notepad++7.3.1" class="phpmain_tab2_mids_title"> <h3>Notepad++7.3.1</h3> </a> <p>Easy-to-use and free code editor</p> </div> </div> <div id="377j5v51b" class="phpmain_tab2_mids_top"> <a href="http://www.miracleart.cn/toolset/development-tools/93" title="SublimeText3 Chinese 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 Chinese version" /> </a> <div id="377j5v51b" class="phpmain_tab2_mids_info"> <a href="http://www.miracleart.cn/toolset/development-tools/93" title="SublimeText3 Chinese version" class="phpmain_tab2_mids_title"> <h3>SublimeText3 Chinese version</h3> </a> <p>Chinese version, very easy to use</p> </div> </div> <div id="377j5v51b" class="phpmain_tab2_mids_top"> <a href="http://www.miracleart.cn/toolset/development-tools/121" title="Zend 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="Zend Studio 13.0.1" /> </a> <div id="377j5v51b" class="phpmain_tab2_mids_info"> <a href="http://www.miracleart.cn/toolset/development-tools/121" title="Zend Studio 13.0.1" class="phpmain_tab2_mids_title"> <h3>Zend Studio 13.0.1</h3> </a> <p>Powerful PHP integrated development environment</p> </div> </div> <div id="377j5v51b" class="phpmain_tab2_mids_top"> <a href="http://www.miracleart.cn/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 id="377j5v51b" class="phpmain_tab2_mids_info"> <a href="http://www.miracleart.cn/toolset/development-tools/469" title="Dreamweaver CS6" class="phpmain_tab2_mids_title"> <h3>Dreamweaver CS6</h3> </a> <p>Visual web development tools</p> </div> </div> <div id="377j5v51b" class="phpmain_tab2_mids_top"> <a href="http://www.miracleart.cn/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 id="377j5v51b" class="phpmain_tab2_mids_info"> <a href="http://www.miracleart.cn/toolset/development-tools/500" title="SublimeText3 Mac version" class="phpmain_tab2_mids_title"> <h3>SublimeText3 Mac version</h3> </a> <p>God-level code editing software (SublimeText3)</p> </div> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR3_more"> <a href="http://www.miracleart.cn/ai">Show More</a> </div> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4"> <div id="377j5v51b" class="phpmain1_4R_readrank"> <div id="377j5v51b" 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>Hot Topics</h2> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottom"> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/gmailyxdlrkzn" title="Where is the login entrance for gmail email?" class="phpgenera_Details_mainR4_bottom_title">Where is the login entrance for gmail email?</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>8637</span> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>17</span> </div> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/java-tutorial" title="Java Tutorial" class="phpgenera_Details_mainR4_bottom_title">Java Tutorial</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1783</span> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>16</span> </div> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/cakephp-tutor" title="CakePHP Tutorial" class="phpgenera_Details_mainR4_bottom_title">CakePHP Tutorial</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1727</span> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>56</span> </div> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/laravel-tutori" title="Laravel Tutorial" class="phpgenera_Details_mainR4_bottom_title">Laravel Tutorial</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1577</span> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>28</span> </div> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms"> <a href="http://www.miracleart.cn/faq/php-tutorial" title="PHP Tutorial" class="phpgenera_Details_mainR4_bottom_title">PHP Tutorial</a> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_info"> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1442</span> </div> <div id="377j5v51b" class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>31</span> </div> </div> </div> </div> <div id="377j5v51b" class="phpgenera_Details_mainR3_more"> <a href="http://www.miracleart.cn/faq/zt">Show More</a> </div> </div> </div> </div> </div> <div id="377j5v51b" class="Article_Details_main2"> <div id="377j5v51b" class="phpgenera_Details_mainL4"> <div id="377j5v51b" 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 id="377j5v51b" class="phpgenera_Details_mainL4_info"> <div id="377j5v51b" class="phphistorical_Version2_mids"> <a href="http://www.miracleart.cn/faq/1796836348.html" title="How to get the current session ID 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/001/431/639/175234695153283.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="How to get the current session ID in PHP?" /> </a> <a href="http://www.miracleart.cn/faq/1796836348.html" title="How to get the current session ID in PHP?" class="phphistorical_Version2_mids_title">How to get the current session ID in PHP?</a> <span id="377j5v51b" class="Articlelist_txts_time">Jul 13, 2025 am 03:02 AM</span> <p class="Articlelist_txts_p">The method to get the current session ID in PHP is to use the session_id() function, but you must call session_start() to successfully obtain it. 1. Call session_start() to start the session; 2. Use session_id() to read the session ID and output a string similar to abc123def456ghi789; 3. If the return is empty, check whether session_start() is missing, whether the user accesses for the first time, or whether the session is destroyed; 4. The session ID can be used for logging, security verification and cross-request communication, but security needs to be paid attention to. Make sure that the session is correctly enabled and the ID can be obtained successfully.</p> </div> <div id="377j5v51b" class="phphistorical_Version2_mids"> <a href="http://www.miracleart.cn/faq/1796836340.html" title="PHP get substring from a string" 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/431/639/175234679154731.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="PHP get substring from a string" /> </a> <a href="http://www.miracleart.cn/faq/1796836340.html" title="PHP get substring from a string" class="phphistorical_Version2_mids_title">PHP get substring from a string</a> <span id="377j5v51b" class="Articlelist_txts_time">Jul 13, 2025 am 02:59 AM</span> <p class="Articlelist_txts_p">To extract substrings from PHP strings, you can use the substr() function, which is syntax substr(string$string,int$start,?int$length=null), and if the length is not specified, it will be intercepted to the end; when processing multi-byte characters such as Chinese, you should use the mb_substr() function to avoid garbled code; if you need to intercept the string according to a specific separator, you can use exploit() or combine strpos() and substr() to implement it, such as extracting file name extensions or domain names.</p> </div> <div id="377j5v51b" class="phphistorical_Version2_mids"> <a href="http://www.miracleart.cn/faq/1796836325.html" title="How do you perform unit testing for php code?" 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/175234647176044.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="How do you perform unit testing for php code?" /> </a> <a href="http://www.miracleart.cn/faq/1796836325.html" title="How do you perform unit testing for php code?" class="phphistorical_Version2_mids_title">How do you perform unit testing for php code?</a> <span id="377j5v51b" class="Articlelist_txts_time">Jul 13, 2025 am 02:54 AM</span> <p class="Articlelist_txts_p">UnittestinginPHPinvolvesverifyingindividualcodeunitslikefunctionsormethodstocatchbugsearlyandensurereliablerefactoring.1)SetupPHPUnitviaComposer,createatestdirectory,andconfigureautoloadandphpunit.xml.2)Writetestcasesfollowingthearrange-act-assertpat</p> </div> <div id="377j5v51b" class="phphistorical_Version2_mids"> <a href="http://www.miracleart.cn/faq/1796836338.html" title="How to split a string into an array 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/001/431/639/175234675030817.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="How to split a string into an array in PHP" /> </a> <a href="http://www.miracleart.cn/faq/1796836338.html" title="How to split a string into an array in PHP" class="phphistorical_Version2_mids_title">How to split a string into an array in PHP</a> <span id="377j5v51b" class="Articlelist_txts_time">Jul 13, 2025 am 02:59 AM</span> <p class="Articlelist_txts_p">In PHP, the most common method is to split the string into an array using the exploit() function. This function divides the string into multiple parts through the specified delimiter and returns an array. The syntax is exploit(separator, string, limit), where separator is the separator, string is the original string, and limit is an optional parameter to control the maximum number of segments. For example $str="apple,banana,orange";$arr=explode(",",$str); The result is ["apple","bana</p> </div> <div id="377j5v51b" class="phphistorical_Version2_mids"> <a href="http://www.miracleart.cn/faq/1796836292.html" title="JavaScript Data Types: Primitive vs Reference" 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/431/639/175234579081669.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="JavaScript Data Types: Primitive vs Reference" /> </a> <a href="http://www.miracleart.cn/faq/1796836292.html" title="JavaScript Data Types: Primitive vs Reference" class="phphistorical_Version2_mids_title">JavaScript Data Types: Primitive vs Reference</a> <span id="377j5v51b" class="Articlelist_txts_time">Jul 13, 2025 am 02:43 AM</span> <p class="Articlelist_txts_p">JavaScript data types are divided into primitive types and reference types. Primitive types include string, number, boolean, null, undefined, and symbol. The values are immutable and copies are copied when assigning values, so they do not affect each other; reference types such as objects, arrays and functions store memory addresses, and variables pointing to the same object will affect each other. Typeof and instanceof can be used to determine types, but pay attention to the historical issues of typeofnull. Understanding these two types of differences can help write more stable and reliable code.</p> </div> <div id="377j5v51b" class="phphistorical_Version2_mids"> <a href="http://www.miracleart.cn/faq/1796837310.html" title="Using std::chrono in C" 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/175251423054720.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Using std::chrono in C" /> </a> <a href="http://www.miracleart.cn/faq/1796837310.html" title="Using std::chrono in C" class="phphistorical_Version2_mids_title">Using std::chrono in C</a> <span id="377j5v51b" class="Articlelist_txts_time">Jul 15, 2025 am 01:30 AM</span> <p class="Articlelist_txts_p">std::chrono is used in C to process time, including obtaining the current time, measuring execution time, operation time point and duration, and formatting analysis time. 1. Use std::chrono::system_clock::now() to obtain the current time, which can be converted into a readable string, but the system clock may not be monotonous; 2. Use std::chrono::steady_clock to measure the execution time to ensure monotony, and convert it into milliseconds, seconds and other units through duration_cast; 3. Time point (time_point) and duration (duration) can be interoperable, but attention should be paid to unit compatibility and clock epoch (epoch)</p> </div> <div id="377j5v51b" class="phphistorical_Version2_mids"> <a href="http://www.miracleart.cn/faq/1796836281.html" title="How to pass a session variable to another page 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/001/431/639/175234556015595.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="How to pass a session variable to another page in PHP?" /> </a> <a href="http://www.miracleart.cn/faq/1796836281.html" title="How to pass a session variable to another page in PHP?" class="phphistorical_Version2_mids_title">How to pass a session variable to another page in PHP?</a> <span id="377j5v51b" class="Articlelist_txts_time">Jul 13, 2025 am 02:39 AM</span> <p class="Articlelist_txts_p">In PHP, to pass a session variable to another page, the key is to start the session correctly and use the same $_SESSION key name. 1. Before using session variables for each page, it must be called session_start() and placed in the front of the script; 2. Set session variables such as $_SESSION['username']='JohnDoe' on the first page; 3. After calling session_start() on another page, access the variables through the same key name; 4. Make sure that session_start() is called on each page, avoid outputting content in advance, and check that the session storage path on the server is writable; 5. Use ses</p> </div> <div id="377j5v51b" class="phphistorical_Version2_mids"> <a href="http://www.miracleart.cn/faq/1796836980.html" title="How does PHP handle Environment Variables?" 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/175243330086297.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="How does PHP handle Environment Variables?" /> </a> <a href="http://www.miracleart.cn/faq/1796836980.html" title="How does PHP handle Environment Variables?" class="phphistorical_Version2_mids_title">How does PHP handle Environment Variables?</a> <span id="377j5v51b" class="Articlelist_txts_time">Jul 14, 2025 am 03:01 AM</span> <p class="Articlelist_txts_p">ToaccessenvironmentvariablesinPHP,usegetenv()orthe$_ENVsuperglobal.1.getenv('VAR_NAME')retrievesaspecificvariable.2.$_ENV['VAR_NAME']accessesvariablesifvariables_orderinphp.iniincludes"E".SetvariablesviaCLIwithVAR=valuephpscript.php,inApach</p> </div> </div> <a href="http://www.miracleart.cn/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 id="377j5v51b" class="footer"> <div id="377j5v51b" class="footertop"> <img src="/static/imghw/logo.png" alt=""> <p>Public welfare online PHP training,Help PHP learners grow quickly!</p> </div> <div id="377j5v51b" class="footermid"> <a href="http://www.miracleart.cn/about/us.html">About us</a> <a href="http://www.miracleart.cn/about/disclaimer.html">Disclaimer</a> <a href="http://www.miracleart.cn/update/article_0_1.html">Sitemap</a> </div> <div id="377j5v51b" class="footerbottom"> <p> ? php.cn All rights reserved </p> </div> </div> </footer> <input type="hidden" id="verifycode" value="/captcha.html"> <link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css?2' type='text/css' media='all' /> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.miracleart.cn/" title="国产av日韩一区二区三区精品">国产av日韩一区二区三区精品</a> <div class="friend-links"> </div> </div> </footer> <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body><div id="brxlv" class="pl_css_ganrao" style="display: none;"><ol id="brxlv"><pre id="brxlv"><track id="brxlv"><tt id="brxlv"></tt></track></pre></ol><ins id="brxlv"><address id="brxlv"></address></ins><legend id="brxlv"></legend><track id="brxlv"><tt id="brxlv"></tt></track><form id="brxlv"><thead id="brxlv"></thead></form><dfn id="brxlv"><ruby id="brxlv"><form id="brxlv"><legend id="brxlv"></legend></form></ruby></dfn><pre id="brxlv"><p id="brxlv"></p></pre><strong id="brxlv"></strong><optgroup id="brxlv"><output id="brxlv"><sub id="brxlv"><big id="brxlv"></big></sub></output></optgroup><output id="brxlv"><em id="brxlv"><big id="brxlv"><dl id="brxlv"></dl></big></em></output><em id="brxlv"><big id="brxlv"></big></em><ins id="brxlv"><pre id="brxlv"></pre></ins><address id="brxlv"><p id="brxlv"></p></address><form id="brxlv"><output id="brxlv"></output></form><b id="brxlv"><meter id="brxlv"><pre id="brxlv"><p id="brxlv"></p></pre></meter></b><i id="brxlv"></i><style id="brxlv"><nobr id="brxlv"></nobr></style><tt id="brxlv"><menuitem id="brxlv"><span id="brxlv"><legend id="brxlv"></legend></span></menuitem></tt><ruby id="brxlv"><form id="brxlv"><thead id="brxlv"><dfn id="brxlv"></dfn></thead></form></ruby><label id="brxlv"></label><form id="brxlv"></form><video id="brxlv"></video><u id="brxlv"></u><var id="brxlv"></var><track id="brxlv"><tt id="brxlv"></tt></track><sub id="brxlv"><div id="brxlv"><ol id="brxlv"><pre id="brxlv"></pre></ol></div></sub><th id="brxlv"><font id="brxlv"></font></th><form id="brxlv"></form><ol id="brxlv"></ol><span id="brxlv"></span><i id="brxlv"><listing id="brxlv"></listing></i><em id="brxlv"></em><form id="brxlv"></form><font id="brxlv"><progress id="brxlv"></progress></font><ol id="brxlv"><optgroup id="brxlv"><track id="brxlv"><em id="brxlv"></em></track></optgroup></ol><output id="brxlv"><sub id="brxlv"><div id="brxlv"><ol id="brxlv"></ol></div></sub></output><strong id="brxlv"><form id="brxlv"></form></strong><track id="brxlv"><tt id="brxlv"></tt></track><strong id="brxlv"><rp id="brxlv"></rp></strong><thead id="brxlv"></thead><pre id="brxlv"><style id="brxlv"></style></pre><form id="brxlv"><output id="brxlv"></output></form><thead id="brxlv"><legend id="brxlv"><sup id="brxlv"><strong id="brxlv"></strong></sup></legend></thead><acronym id="brxlv"></acronym><track id="brxlv"><tt id="brxlv"></tt></track><label id="brxlv"></label><thead id="brxlv"><legend id="brxlv"><label id="brxlv"><strong id="brxlv"></strong></label></legend></thead><thead id="brxlv"></thead><th id="brxlv"><font id="brxlv"><progress id="brxlv"><acronym id="brxlv"></acronym></progress></font></th><font id="brxlv"></font><thead id="brxlv"></thead><u id="brxlv"></u><p id="brxlv"><var id="brxlv"><form id="brxlv"><output id="brxlv"></output></form></var></p><strong id="brxlv"><optgroup id="brxlv"></optgroup></strong><rp id="brxlv"><form id="brxlv"></form></rp><form id="brxlv"><output id="brxlv"></output></form><pre id="brxlv"><track id="brxlv"><tt id="brxlv"><big id="brxlv"></big></tt></track></pre><optgroup id="brxlv"></optgroup><strike id="brxlv"><strong id="brxlv"><form id="brxlv"><output id="brxlv"></output></form></strong></strike><var id="brxlv"><form id="brxlv"><output id="brxlv"><sub id="brxlv"></sub></output></form></var><track id="brxlv"></track><label id="brxlv"><strong id="brxlv"></strong></label><pre id="brxlv"><listing id="brxlv"><tt id="brxlv"><mark id="brxlv"></mark></tt></listing></pre><u id="brxlv"><ruby id="brxlv"></ruby></u><big id="brxlv"><dl id="brxlv"></dl></big><i id="brxlv"><listing id="brxlv"></listing></i><ins id="brxlv"><address id="brxlv"><strike id="brxlv"><strong id="brxlv"></strong></strike></address></ins><p id="brxlv"><var id="brxlv"></var></p><big id="brxlv"><span id="brxlv"><i id="brxlv"><track id="brxlv"></track></i></span></big><div id="brxlv"><var id="brxlv"></var></div><p id="brxlv"></p><dfn id="brxlv"><strong id="brxlv"><ruby id="brxlv"><thead id="brxlv"></thead></ruby></strong></dfn><b id="brxlv"><meter id="brxlv"></meter></b><p id="brxlv"><var id="brxlv"></var></p><legend id="brxlv"></legend><listing id="brxlv"><tt id="brxlv"></tt></listing><dfn id="brxlv"><u id="brxlv"><ruby id="brxlv"><thead id="brxlv"></thead></ruby></u></dfn><output id="brxlv"><em id="brxlv"><div id="brxlv"><ol id="brxlv"></ol></div></em></output><ruby id="brxlv"></ruby><pre id="brxlv"><p id="brxlv"></p></pre><ins id="brxlv"></ins><rp id="brxlv"><font id="brxlv"><progress id="brxlv"><acronym id="brxlv"></acronym></progress></font></rp><optgroup id="brxlv"><output id="brxlv"></output></optgroup><i id="brxlv"><track id="brxlv"></track></i><listing id="brxlv"><dfn id="brxlv"></dfn></listing><thead id="brxlv"><dfn id="brxlv"><strong id="brxlv"><ruby id="brxlv"></ruby></strong></dfn></thead><legend id="brxlv"></legend><legend id="brxlv"><dfn id="brxlv"><dfn id="brxlv"><menuitem id="brxlv"></menuitem></dfn></dfn></legend><listing id="brxlv"><tt id="brxlv"><menuitem id="brxlv"><span id="brxlv"></span></menuitem></tt></listing><sup id="brxlv"><strong id="brxlv"><rp id="brxlv"><font id="brxlv"></font></rp></strong></sup><u id="brxlv"></u><div id="brxlv"><ol id="brxlv"></ol></div><b id="brxlv"><meter id="brxlv"></meter></b><strong id="brxlv"></strong><output id="brxlv"></output><p id="brxlv"><var id="brxlv"></var></p><th id="brxlv"><font id="brxlv"></font></th><form id="brxlv"><legend id="brxlv"><dfn id="brxlv"><dfn id="brxlv"></dfn></dfn></legend></form><track id="brxlv"><sub id="brxlv"><div id="brxlv"><strong id="brxlv"></strong></div></sub></track><sup id="brxlv"><strong id="brxlv"><rp id="brxlv"><thead id="brxlv"></thead></rp></strong></sup></div> </html>