本文執行個體講述了php刪除指定目錄的方法。分享給大家供大家參考。具體分析如下:這段代碼可實現遞迴刪除子目錄的功能<?php/** * Delete a file, or a folder and its contents * (recursive algorithm) * @author Aidan Lister <aidan@php.net> * @version 1.0.3 * @param string $dirname Directory to
本文執行個體講述了php解析字串裡所有URL地址的方法。分享給大家供大家參考。具體如下:<?php// $html = the html on the page// $current_url = the full url that the html came from//(only needed for $repath)// $repath = converts ../ and / and // urls to full valid urlsfunction pageLinks($
本文執行個體講述了php實現在限定地區裡自動調整字型大小的類。分享給大家供大家參考。具體如下:這裡的php類imagefittext.class.php實現在限定的地區裡自動調整字型大小的功能。<?php// Image Fit Text Class 0.1 by ming0070913CLASS ImageFitText{ public $font, $fontsize, $width, $height; public $step_wrap, $step_fontsize;
本文執行個體講述了php實現TCP連接埠檢測的方法。分享給大家供大家參考。具體如下:該程式可以確認當前連接埠是否可用:<?phpclass Health { public static $status; public function __construct() { } public function check($ip, $port){ $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_
本文執行個體講述了PHP遞迴調用數組值並用其執行指定函數的方法。分享給大家供大家參考。具體分析如下:以下為wordpress原代碼,為了偷懶,簡單修改一下以適用其它函數/*** Navigates through an array and removes slashes from the values.** If an array is passed, the array_map() function causes a callback to pass the* value back to
本文執行個體講述了php使用Image Magick將PDF檔案轉換為JPG檔案的方法。分享給大家供大家參考。具體如下:這是一個非常簡單的格式轉碼,可以把.PDF檔案轉換為.JPG檔案,代碼要起作用,伺服器必須要安裝Image Magick 擴充。$pdf_file = './pdf/demo.pdf';$save_to = './jpg/demo.jpg';//make sure that apache has permissions to write in this folder! //
本文執行個體講述了php給一組指定關鍵詞添加span標籤的方法。分享給大家供大家參考。具體如下:這裡是php給一組指定的關鍵詞添加span標籤,高亮反白關鍵詞// Example use: $spanned = codeWords($string_containing_keywords);// My site: andrew.dx.am// Using colour==blue, but different arrays of words and different // colours