Home Backend Development PHP Tutorial Adding watermark to php pictures and adding watermark to uploaded pictures php class_PHP tutorial

Adding watermark to php pictures and adding watermark to uploaded pictures php class_PHP tutorial

Jul 21, 2016 pm 03:38 PM
php upload and add picture picture exist Increase regular watermark of kind website need

When a regular website needs to upload pictures, it often needs to add its own website's LOGO watermark to the pictures. So how to implement this step? First, let us understand the principle of watermarking PHP images.
Create a graphic by determining the file type, then copy it to the originally created graphic, fill in and create a rectangle, ready to be written to imagestring() or to determine the watermark type in the original image program: First, string , the other is to add a graphics object on top. The following is a reprint of the PHP image with watermark!

Parameter description:

$max_file_size: upload file size limit, unit BYTE
$destination_folder: upload file path
$watermark: whether to attach a watermark (1 means adding watermark, others (To not add watermark);

Instructions for adding watermark to PHP images:
1. Remove the ; sign in front of the "extension=php_gd2.dll" line in the PHP.INI file, because we need to use it GD library;
2. Change extension_dir = to the directory where your php_gd2.dll is located;
3. http://www.jb51.net/list/list_15_1.htm
Code for watermarking PHP images Example:

Copy code The code is as follows:

//Upload file type list
$uptypes=array(
'image/jpg',
'image/jpeg',
'image/png',
'image/pjpeg',
'image/gif',
'image/bmp',
'image/x-png'
);
$max_file_size=2000000; //Upload File size limit, unit BYTE
$destination_folder="uploadimg/"; //Upload file path
$watermark=1; //Whether to attach a watermark (1 means adding watermark, others means not adding watermark);
$watertype=1; //Watermark type (1 is text, 2 is picture)
$waterposition=1; //Watermark position (1 is the lower left corner, 2 is the lower right corner
, 3 is the upper left corner, 4 is the upper right corner, 5 is in the center);
$waterstring="
http://www.xplore.cn/< ;/A>"; //Watermark string
$waterimg="xplore.gif"; //Watermark image
$imgpreview=1; //Whether to generate a preview image (1 means generated, others will not be generated) );
$imgpreviewsize=1/2; //Thumbnail ratio
?>


ZwelL image uploader< /title> <br><style type="text/css"> <br><!-- <BR>body <BR>{ <BR>font-size: 9pt; <BR>} <BR> input <BR>{ <BR>background-color: #66CCFF; <BR>border: 1px inset #CCCCCC; <BR>} <BR>--> <br></style> <br></ head> <br><body> <br><form enctype="multipart/form-data" <BR>method="post" name="upform"> <br>Upload file: <br>< input name="upfile" type="file"> <br><input type="submit" value="Upload"><br> <br>The file types allowed to be uploaded are:<?=implode (', ',$uptypes)?> <br></form> <br><?php <BR>if ($_SERVER['REQUEST_METHOD'] == 'POST') <BR>{ <BR>if (!is_uploaded_file($_FILES["upfile"] <BR>[tmp_name])) <BR>//Whether the file exists<BR>{ <BR>echo "The picture does not exist!"; <BR>exit; <BR>} <BR>$file = $_FILES["upfile"]; <BR>if($max_file_size <$file["size"]) <BR>//Check file size<BR>{ <BR>echo "The file is too big!"; <BR>exit; <BR>} <BR>if(!in_array($file["type"], $uptypes)) <BR>//Check the file type<BR>{ <BR>echo "File type does not match!".$file["type"]; <BR>exit; <BR>} <BR>if(!file_exists($destination_folder)) <BR>{ <BR>mkdir($destination_folder) ; <BR>} <BR>$filename=$file["tmp_name"]; <BR>$image_size = getimagesize($filename); <BR>$pinfo=pathinfo($file["name"]); <BR>$ftype=$pinfo['extension']; <BR>$destination = $destination_folder. <BR>time().".".$ftype; <BR>if (file_exists($destination) && <BR>$ overwrite != true) <BR>{ <BR>echo "The file with the same name already exists"; <BR>exit; <BR>} <BR>if(!move_uploaded_file ($filename, <BR>$destination)) <BR>{ <BR>echo "Error moving file"; <BR>exit; <BR>} <BR>$pinfo=pathinfo($destination); <BR>$fname=$pinfo[basename]; <BR>echo " <font color=red>Uploaded successfully<br></font><br>File name: <br><font color=blue>".$destination_folder. <br>$fname."</ font><br>"; <br>echo " width:".$image_size[0]; <br>echo " length:".$image_size[1]; <br>echo "<br> size:" .$file["size"]." bytes"; <br>if($watermark==1) <br>{ <br>$iinfo=getimagesize($destination,$iinfo); <br>$nimage=imagecreatetruecolor ($image_size[0] <br>,$image_size[1]); <br>$white=imagecolorallocate($nimage,255,255,255); <br>$black=imagecolorallocate($nimage,0,0,0); <br>$red=imagecolorallocate($nimage,255,0,0); <br>imagefill($nimage,0,0,$white); <br>switch ($iinfo[2]) <br>{ <br>case 1: <br>$simage =imagecreatefromgif($destination); <br>break; <br>case 2: <br>$simage =imagecreatefromjpeg($destination); <br>break; <br>case 3: <br>$simage =imagecreatefrompng($destination); <br>break; <br>case 6: <br>$simage =imagecreatefromwbmp($destination); <br>break; <br>default: <br>die( "Unsupported file type"); <br>exit; <br>} <br>imagecopy($nimage,$simage,0,0,0,0, <br>$image_size[0],$image_size[1 ]); <br>imagefilledrectangle($nimage,1, <br>$image_size[1]-15,80,$image_size[1],$white); <br>switch($watertype) <br>{ <br>case 1: //Add watermark string<br>imagestring($nimage,2,3,$image_size[1]-15, <br>$waterstring,$black); <br>break; <br>case 2 : //Watermark image<br>$simage1 =imagecreatefromgif("xplore.gif"); <br>imagecopy($nimage,$simage1,0,0,0,0,85,15); <br>imagedestroy( $simage1); <br>break; <br>} <br>switch ($iinfo[2]) <br>{ <br>case 1: <br>//imagegif($nimage, $destination); <br>imagejpeg($nimage, $destination); <br>break; <br>case 2: <br>imagejpeg($nimage, $destination); <br>break; <br>case 3: <br>imagepng($ nimage, $destination); <br>break; <br>case 6: <br>imagewbmp($nimage, $destination); <br>//imagejpeg($nimage, $destination); <br>break; <br>} <br>//Overwrite the original uploaded file <br>imagedestroy($nimage); <br>imagedestroy($simage); <br>}<br>if($imgpreview==1) <br>{ <br>echo "<br>Image preview:<br>"; <br>echo "<ccid_file values="" width=". <BR>($image_size[0]*$imgpreviewsize)." <BR>height=".($image_size[1]*$imgpreviewsize);" <BR>echo " alt="Image preview:rFile name:". <BR>$destination."rUpload time:" />"; <br>} <br>} <br>?> <br></body> <br></html> <br> </div> <br><br>You can also refer to the PHP class for adding watermarks to pictures <p align="left"></p> <div style="display:none;"> <span id="url" itemprop="url">http://www.bkjia.com/PHPjc/321772.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/321772.html</span><span id="genre" itemprop="genre">TechArticle</span><span id="description" itemprop="description">A regular website often needs to add its own website’s LOGO watermark to the image when uploading pictures. So how to implement this step? First let us understand PHP images...</span> </div> <div class="art_confoot"></div> </div> </div> <div class="wzconShengming_sp"> <div 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> <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>Hot Article</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/1796780570.html" title="R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>2 weeks ago</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/1796773439.html" title="Repo: How To Revive Teammates" class="phpgenera_Details_mainR4_bottom_title">Repo: How To Revive Teammates</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>4 weeks ago</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/1796774171.html" title="Hello Kitty Island Adventure: How To Get Giant Seeds" class="phpgenera_Details_mainR4_bottom_title">Hello Kitty Island Adventure: How To Get Giant Seeds</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>4 weeks ago</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/1796775427.html" title="How Long Does It Take To Beat Split Fiction?" class="phpgenera_Details_mainR4_bottom_title">How Long Does It Take To Beat Split Fiction?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3 weeks ago</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/1796775336.html" title="R.E.P.O. Save File Location: Where Is It & How to Protect It?" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O. Save File Location: Where Is It & How to Protect It?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3 weeks ago</span> <span>By DDD</span> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/article.html">Show More</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>Hot AI Tools</h2> </div> <div class="phpgenera_Details_mainR3_bottom"> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.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 class="phpmain_tab2_mids_info"> <a href="https://www.php.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 class="phpmain_tab2_mids_top"> <a href="https://www.php.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 class="phpmain_tab2_mids_info"> <a href="https://www.php.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 class="phpmain_tab2_mids_top"> <a href="https://www.php.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 class="phpmain_tab2_mids_info"> <a href="https://www.php.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 class="phpmain_tab2_mids_top"> <a href="https://www.php.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 class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_title"> <h3>Clothoff.io</h3> </a> <p>AI clothes remover</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/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/ai/ai-hentai-generator" title="AI Hentai Generator" class="phpmain_tab2_mids_title"> <h3>AI Hentai Generator</h3> </a> <p>Generate AI Hentai for free.</p> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/ai">Show More</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>Hot Article</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/1796780570.html" title="R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>2 weeks ago</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/1796773439.html" title="Repo: How To Revive Teammates" class="phpgenera_Details_mainR4_bottom_title">Repo: How To Revive Teammates</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>4 weeks ago</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/1796774171.html" title="Hello Kitty Island Adventure: How To Get Giant Seeds" class="phpgenera_Details_mainR4_bottom_title">Hello Kitty Island Adventure: How To Get Giant Seeds</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>4 weeks ago</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/1796775427.html" title="How Long Does It Take To Beat Split Fiction?" class="phpgenera_Details_mainR4_bottom_title">How Long Does It Take To Beat Split Fiction?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3 weeks ago</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/1796775336.html" title="R.E.P.O. Save File Location: Where Is It & How to Protect It?" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O. Save File Location: Where Is It & How to Protect It?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3 weeks ago</span> <span>By DDD</span> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/article.html">Show More</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>Hot Tools</h2> </div> <div class="phpgenera_Details_mainR3_bottom"> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.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 class="phpmain_tab2_mids_info"> <a href="https://www.php.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 class="phpmain_tab2_mids_top"> <a href="https://www.php.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 class="phpmain_tab2_mids_info"> <a href="https://www.php.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 class="phpmain_tab2_mids_top"> <a href="https://www.php.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 class="phpmain_tab2_mids_info"> <a href="https://www.php.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 class="phpmain_tab2_mids_top"> <a href="https://www.php.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 class="phpmain_tab2_mids_info"> <a href="https://www.php.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 class="phpmain_tab2_mids_top"> <a href="https://www.php.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 class="phpmain_tab2_mids_info"> <a href="https://www.php.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 class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/ai">Show More</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>Hot Topics</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.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 class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>7323</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>9</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/java-tutorial" title="Java Tutorial" class="phpgenera_Details_mainR4_bottom_title">Java Tutorial</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1625</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>14</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/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>1350</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>46</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/laravel-tutori" title="Laravel Tutorial" class="phpgenera_Details_mainR4_bottom_title">Laravel Tutorial</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1262</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>25</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/faq/php-tutorial" title="PHP Tutorial" class="phpgenera_Details_mainR4_bottom_title">PHP Tutorial</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1209</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>29</span> </div> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/faq/zt">Show More</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/faq/1796604977.html" title="CakePHP Project Configuration" 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/202409/10/2024091017250464952.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="CakePHP Project Configuration" /> </a> <a href="https://www.php.cn/faq/1796604977.html" title="CakePHP Project Configuration" class="phphistorical_Version2_mids_title">CakePHP Project Configuration</a> <span class="Articlelist_txts_time">Sep 10, 2024 pm 05:25 PM</span> <p class="Articlelist_txts_p">In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/faq/1796733273.html" title="PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian" 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/000/000/080/676a727698393240.png?x-oss-process=image/resize,m_fill,h_207,w_330" alt="PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian" /> </a> <a href="https://www.php.cn/faq/1796733273.html" title="PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian" class="phphistorical_Version2_mids_title">PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian</a> <span class="Articlelist_txts_time">Dec 24, 2024 pm 04:42 PM</span> <p class="Articlelist_txts_p">PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/faq/1796604998.html" title="CakePHP Date and Time" 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/000/887/227/172596042710877.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="CakePHP Date and Time" /> </a> <a href="https://www.php.cn/faq/1796604998.html" title="CakePHP Date and Time" class="phphistorical_Version2_mids_title">CakePHP Date and Time</a> <span class="Articlelist_txts_time">Sep 10, 2024 pm 05:27 PM</span> <p class="Articlelist_txts_p">To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/faq/1796604999.html" title="CakePHP File upload" 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/000/000/164/172596043255110.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="CakePHP File upload" /> </a> <a href="https://www.php.cn/faq/1796604999.html" title="CakePHP File upload" class="phphistorical_Version2_mids_title">CakePHP File upload</a> <span class="Articlelist_txts_time">Sep 10, 2024 pm 05:27 PM</span> <p class="Articlelist_txts_p">To work on file upload we are going to use the form helper. Here, is an example for file upload.</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/faq/1796604978.html" title="CakePHP Routing" 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/000/465/014/172596030742788.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="CakePHP Routing" /> </a> <a href="https://www.php.cn/faq/1796604978.html" title="CakePHP Routing" class="phphistorical_Version2_mids_title">CakePHP Routing</a> <span class="Articlelist_txts_time">Sep 10, 2024 pm 05:25 PM</span> <p class="Articlelist_txts_p">In this chapter, we are going to learn the following topics related to routing ?</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/faq/1796605002.html" title="Discuss CakePHP" 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/202409/10/2024091017281739989.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Discuss CakePHP" /> </a> <a href="https://www.php.cn/faq/1796605002.html" title="Discuss CakePHP" class="phphistorical_Version2_mids_title">Discuss CakePHP</a> <span class="Articlelist_txts_time">Sep 10, 2024 pm 05:28 PM</span> <p class="Articlelist_txts_p">CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/faq/1796728164.html" title="How To Set Up Visual Studio Code (VS Code) for PHP Development" 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/000/000/080/6764e39e44ffe544.png?x-oss-process=image/resize,m_fill,h_207,w_330" alt="How To Set Up Visual Studio Code (VS Code) for PHP Development" /> </a> <a href="https://www.php.cn/faq/1796728164.html" title="How To Set Up Visual Studio Code (VS Code) for PHP Development" class="phphistorical_Version2_mids_title">How To Set Up Visual Studio Code (VS Code) for PHP Development</a> <span class="Articlelist_txts_time">Dec 20, 2024 am 11:31 AM</span> <p class="Articlelist_txts_p">Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/faq/1796604997.html" title="CakePHP Creating Validators" 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/000/000/164/172596041825531.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="CakePHP Creating Validators" /> </a> <a href="https://www.php.cn/faq/1796604997.html" title="CakePHP Creating Validators" class="phphistorical_Version2_mids_title">CakePHP Creating Validators</a> <span class="Articlelist_txts_time">Sep 10, 2024 pm 05:26 PM</span> <p class="Articlelist_txts_p">Validator can be created by adding the following two lines in the controller.</p> </div> </div> <a href="https://www.php.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 class="footer"> <div class="footertop"> <img src="/static/imghw/logo.png" alt=""> <p>Public welfare online PHP training,Help PHP learners grow quickly!</p> </div> <div class="footermid"> <a href="https://www.php.cn/about/us.html">About us</a> <a href="https://www.php.cn/about/disclaimer.html">Disclaimer</a> <a href="https://www.php.cn/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?1743548848"></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>