Time of Update: 2017-01-19
PHP代碼如下:複製代碼 代碼如下:if (isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) { $upload_file = $_FILES['Filedata']; $file_info = pathinfo($
Time of Update: 2017-01-19
在php中漢字正則可能有些朋友覺得很簡單,但是在使用時會發現在gbk編碼與uft8編碼可能會有點區別哦,下面小編來介紹一下。gbk編碼下漢字正則1.判斷字串是否全是漢字複製代碼 代碼如下:<?php $str = '全部是漢字測試'; if (preg_match_all("/^([x81-xfe][x40-xfe])+$/", $str, $match))
Time of Update: 2017-01-19
從網上搜集到的,據說是雅虎的面試題。 1. Which of the following will not add john to the users array? 1. $users[] = 'john'; 2. array_add($users,'john'); //wrong 3. array_push($users,'john'); 4. $users ||= 'john'; //wrong 2. What's the difference between sort(), asort()
Time of Update: 2017-01-19
printf()函數優點在於可以格式化輸出!printf的格式控制的完整格式: % - 0 m.n l或h
Time of Update: 2017-01-19
本文執行個體講述了php基於jquery的ajax技術傳遞json資料簡單實現方法。分享給大家供大家參考,具體如下:html頁面:<html><head><meta http-equiv="content-type" content="text/html;charset=utf-8" /><script type="text/javascript"
Time of Update: 2017-01-19
PHP內建的mail函數比較蛋疼,在win下配置了sendmail還是無法發送郵件。而使用第三方的pear/mail可以直接通過smtp串連郵件發送伺服器。如(smtp.163.com)。從而沒有必要在本機上安裝sendmail等類似軟體。確保PEAR Mail包已經安裝。<?php require_once "vendor/autoload.php"; $from = "test<test@163.com>"; $to = "test
Time of Update: 2017-01-19
PHP發郵件可以用其內建mail()函數,但是這個函數很不好使,需要配置郵件伺服器,並且不支援smtp驗證,在很多場合無法正常的工作. 找了個代碼發郵件,但總是出錯,我在這裡用PEAR的Mail類,使用smtp發郵件.首先安裝,我推陳用最新版的PHP5,因為我用PHP4出現了很多問題,大多是因為那些封裝好的類版本太高,與PHP4不相容的原故吧.安裝方法:1.在php目錄中雙擊go-pear.bat。2.按照提示輸入一些設定資訊,主要是問直接存取外網,還是用代理,若無Proxy
Time of Update: 2017-01-19
思維導圖點擊下圖,可以看具體內容!介紹Regex,大家在開發中應該是經常用到,現在很多開發語言都有Regex的應用,比如javascript,java,.net,php等等,我今天就把我對Regex的理解跟大家嘮嘮,不當之處,請多多指教!定位我們什麼時候使用Regex呢?不是所有的字元操作都用正則就好了,php在某些方面用正則反而影響效率。當我們遇到複雜文本資料的解析時候,用正則是比較好的選擇。優點Regex在處理複雜字元操作的時候,可以提高工作效率,也在一定程度節省你的代碼量。缺點我們在使用R
Time of Update: 2017-01-19
本文執行個體講述了PHP圖片加浮水印實現方法。分享給大家供大家參考,具體如下:<?phpecho img_water_mark("2008112023204423477802.gif", "copyImg.png", $savepath=null, $savename="123.gif", $positon=2, $alpha=60);/** * 圖片加浮水印(適用於png/jpg/gif格式) * * @author flynetcn * * @param $srcImg
Time of Update: 2017-01-19
本文執行個體講述了PHP字串中插入子字串方法。分享給大家供大家參考,具體如下:首先來看看一個網上常見的方法:方法一:字串遍曆function str_insert($str, $i, $substr){ for($j=0; $j<$i; $j++){ $startstr .= $str[$j]; } for ($j=$i; $j<strlen($str); $j++){ $laststr .= $str[$j]; } $str = ($startstr .
Time of Update: 2017-01-19
本文執行個體講述了php求數組全排列,元素所有組合的方法。分享給大家供大家參考,具體如下:<?php$source = array('pll','我','愛','你','嘿');sort($source); //保證初始數組是有序的$last = count($source) - 1; //$source尾部元素下標$x = $last;$count = 1; //組合個數統計echo implode(',', $source), "<br>";
Time of Update: 2017-01-19
本文執行個體講述了php遍曆解析xml字串的方法。分享給大家供大家參考,具體如下:<?php$content = <<<XML<?xml version="1.0" encoding="UTF-8"?><test> <global_setting> <ping_protocol>HTTP</ping_protocol>
Time of Update: 2017-01-19
複製代碼 代碼如下:/*********************/ /* */ /* Version : 5.2.5 */ /* Author : liqiangwork#sohu.com */ /* QQ : 570937581 */ /* */ /*********************/ //-----------------------------產生靜態類------------------------------- class Makehtml{ public
Time of Update: 2017-01-19
本文執行個體講述了PHP簡單建立日曆的方法。分享給大家供大家參考,具體如下:<?phpfunction build_calendar($month,$year) { // Create array containing abbreviations of days of week. $daysOfWeek = array('S','M','T','W','T','F','S'); // What is the first day of the month in
Time of Update: 2017-01-19
調用方法:<script language = "javascript" src = "count.php"></script> count.php源碼:複製代碼 代碼如下:<?php $file_name = "count.txt"; $fp = fopen($file_name,"r"); //開啟檔案讀入當前計數 $count = fread($fp, filesize($file_name)); fclose($fp); $count++; //計數加1 $
Time of Update: 2017-01-19
本文執行個體講述了php使用ffmpeg擷取視頻資訊並截圖的方法。分享給大家供大家參考,具體如下:$movie = new ffmpeg_movie('4.mp4');$width=$movie->getFrameWidth();$height=$movie->getFrameHeight();$count= $movie->getFrameCount();print $count . '';$n = round ( $count/16 );print $n . '';for
Time of Update: 2017-01-19
本文執行個體講述了Linux環境下php實現給網站截圖的方法。分享給大家供大家參考,具體如下:第一步:下載wkhtmltopdf複製代碼 代碼如下:[root@iZ94aawoublZ ~]# wget http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz第二步:解壓複製代碼 代碼如下:[root@iZ94aawoublZ ~]# xz -d wkhtmltox-0.
Time of Update: 2017-01-19
1. 截取GB2312中文字串 複製代碼 代碼如下:<?php //截取中文字串 function mysubstr($str, $start, $len) { $tmpstr = ""; $strlen = $start + $len; for($i = 0; $i < $strlen; $i++) { if(ord(substr($str, $i, 1)) > 0xa0) { $tmpstr .= substr($str, $i, 2); $i++; }
Time of Update: 2017-01-19
本文執行個體講述了php簡單建立zip壓縮檔的方法。分享給大家供大家參考,具體如下:/* creates a compressed zip file */function create_zip($files = array(),$destination = '',$overwrite = false) { //if the zip file already exists and overwrite is false, return false
Time of Update: 2017-01-19
代碼如下: 複製代碼 代碼如下:<?php session_start(); define ('P_S', PATH_SEPARATOR); define ('ROOT', "./"); set_include_path(ROOT .P_S .'Zend' .P_S .ROOT.get_include_path()); //載入ZEND 架構 require_once ROOT.'Zend/Loader.php'; require_once