Time of Update: 2016-07-25
本文介紹下,php中常用的數組排序方法,包括php數組排序函數的用法,php中一維數組、二維及多維陣列的排序方法,感興趣的朋友不要錯過哦。我們知道,在php編程中,有關php數組排序的內容,一直是很重要的一個知識點。本節為大家整理了些php中數組排序的文章,其中包含php數組排序函數的用法,php中一維、二維、多維陣列的排序方法與執行個體。熟讀並掌握了本文介紹的這些方法與技巧,相信您對php
Time of Update: 2016-07-25
include("config.php");// load libraryrequire 'php-excel.class.php';// create a simple 2-dimensional array//@mysql_query("set character set gb2312");$strSql="select * from booklist";$result=mysql_query($strSql);//print_r($result);$data = array(1 =>
Time of Update: 2016-07-25
public function getimgsinarticle($content) { $temp = array(); $imgs = array(); preg_match_all('/http[^\d]*[\d]+[\.](jpg|gif|png)/',$content,$temp); $temp = $temp[0]; if(!empty($temp[0])) { for($i=0;$i { $imgs[$i] = pathinfo($temp[$i]);
Time of Update: 2016-07-25
/** php產生折線圖* by bbs.it-home.org*/function line_stats_pic($value_y,$width,$high,$strong=1,$fix=0){ //y值處理函數 function line_point_y($num,$width,$high,$max_num_add,$min_num_add,$y_pxdensity){
Time of Update: 2016-07-25
本文介紹下,php環境下的php-fpm的配置方法,對php-fpm的配置選項及方法作下詳細的介紹,有需要的朋友參考下。本節內容:php-fpm配置配置php-fpm:pid = run/php-fpm.pidpid設定,預設在安裝目錄中的var/run/php-fpm.pid,建議開啟error_log = log/php-fpm.log錯誤記錄檔,預設在安裝目錄中的var/log/php-fpm.loglog_level = notice錯誤層級。可用層級為:
Time of Update: 2016-07-25
$a = 'Original'; $my_array = array("a" => "Cat","b" => "Dog", "c" => "Horse"); extract($my_array); echo "\$a = $a; \$b = $b; \$c = $c"; ?>複製代碼輸出:$a = Cat; $b = Dog; $c = Horse例子 2 使用全部參數: $a = 'Original'; $my_array = array("a" => "Cat","b" => "Dog",
Time of Update: 2016-07-25
頁面標題 您好! 複製代碼用 ie 瀏覽器開啟網站的這一頁面。可以看到,頁面顯示正常。在 ie 瀏覽器的“查看”/“編碼”菜單下看到(勾選了“自動選擇”),字元編碼是 gb2312。[firefox 2.0 下顯示正常。]1.2 然後,在 ultraedit 的[檔案] 功能表下,選“另存新檔”,格式選擇“utf-8”,檔案名稱為 test2.php。用 ie 瀏覽器開啟這一頁面。可以看到,頁面顯示正常(其實英文字型已經有略微的變化了)。在 ie 瀏覽器的“查看”/“編碼”菜單下看到(勾選了“
Time of Update: 2016-07-25
for($i=0; $i echo $i.''; sleep(2); } ?> 複製代碼運行結果:等所有指令碼全部運行完成後,才輸出,因為資料未滿一個buffer的大小。例2,output_buffering=4096,輸出較少的資料(少於一個buffer),關閉output_buffering,修改php.ini的output_buffering=0 for($i=0; $i echo $i.str_repeat(" ",500).''; // 當接受到的256(
Time of Update: 2016-07-25
$con = file_get_contents("http://bbs.it-home.org/news/jb-1.html");$pattern="//";preg_match_all($pattern,$con,$match);print_r($match);?>複製代碼輸出結果:Array( [0] => Array ( [0] => [1] => [2] => ) [1] =
Time of Update: 2016-07-25
win8 64位旗艦版系統背景程式切換的兩種方法
Time of Update: 2016-07-25
/*** php防止sql注入* by bbs.it-home.org*/class sqlsafe { private $getfilter = "'|(and|or)\\b.+?(>| private $postfilter = "\\b(and|or)\\b.{1,6}?(=|>| private $cookiefilter = "\\b(and|or)\\b.{1,6}?(=|>| /** * 建構函式 */ public function __construct() {
Time of Update: 2016-07-25
$filename="./files.text"; $fp=fopen($finename,"rb"); $encho fread($fp,100); ?>複製代碼readfile(),file()和file_get_contents()函數. readfile(),file()和file_get_contents()函數. int readfile(string filename[,bool use_include_path,resource
Time of Update: 2016-07-25
$str="'324是"; if(!eregi("[^\x80-\xff]","$str")){ echo "全是中文"; }else{ echo "不是"; }複製代碼二,判斷含有中文 $str = "中文"; if (preg_match("/[\x7f-\xff]/", $str)) { echo "含有中文"; }else{ echo "沒有中文"; } 或 $pattern = '/[^\x00-\x80]/'; if(preg_match($pattern,$str)){
Time of Update: 2016-07-25
$name = 'yutuo';// 單引號字串echo 'my name is $name';// 單引號字串echo "my name is $name";echo "my name is {$name}";// here文檔字串echo my name is $namemy name is {$name}end; 複製代碼其結果為(輸出沒有任何換行,為了容易理解,在結果裡換行了):my name is $namemy name is yutuomy name is yutuomy
Time of Update: 2016-07-25
本文介紹下,在php中匯入與匯出excel檔案的辦法,使用phpexcel或Spreadsheet_Excel_Writer類匯出excel檔案,並介紹了匯出csv檔案的三種方法。一、PHP匯出Excel檔案1,推薦phpexcel,官方網站: http://www.codeplex.com/PHPExcel匯入匯出都成,可以匯出office2007格式,同時相容20032、使用pear的Spreadsheet_Excel_Writer類下載地址:
Time of Update: 2016-07-25
//解決strip_tags的bugfunction fixtags ($text) {$text = htmlspecialchars($text);$text = preg_replace("/"/", ""\"", $text);$tags = "/<(!|)(\/|)(\w*)(\ |)(\w*)([\\\=]*)(?|(\")\""\"|)(?|(.*)?"(\")|)([\ ]?)(\/|)>/i";$replacement = "
Time of Update: 2016-07-25
$content = iconv("utf-8","gb2312",$content);複製代碼這樣做其實也對著了,看著確實是把utf-8轉化為gb2312了,但是實際啟動並執行話,往往都是以失敗告終的,原因呢?原因很簡單,因為任何的函數都是執行錯誤的時候,同時很不幸的是iconv();就很終於出現錯誤。正確做法: $content =
Time of Update: 2016-07-25
class person{ var $name; var $age; function __construct(){// 建構函式 $this->name="lisi"; $this->age=28; } function say(){ echo "my name is ".$this->name.""; echo "my age is ".$this->age.""; } }$per=new
Time of Update: 2016-07-25
//漢字轉換為16進位編碼function hexencode($s) { return preg_replace('/(.)/es',"str_pad(dechex(ord('\\1')),2,'0',str_pad_left)",$s); }//16進位編碼轉換為漢字function hexdecode($s) { return preg_replace('/(\w{2})/e',"chr(hexdec('\\1'))",$s);}echo
Time of Update: 2016-07-25
複製代碼當採用 curl 在不注意細節的前提下向伺服器發送一些資料,可能得到下面這樣的結果,這不是理想中的結果: [content_type] => multipart/form-data; boundary=—————————-f924413ea122複製代碼但是如果在採用 http_build_query($post_data) 來替代 $post_data 再向這個 php 指令碼提交資料時,就會得到和上面不同的結果,這才是理想中的結果: [content_type] =>