Time of Update: 2018-12-08
這個抽獎小程式,在實際的測試環境中也可以用到,比方說測試資料的查詢在in條件下,要查詢隨機的5個id,然後在用ab去壓測 複製代碼 代碼如下:<?php /** * “抽獎”函數 * * @param integer $first 起始編號 * @param integer $last 結束編號 * @param integer $total 獲獎人數 * * @return string * */ function
Time of Update: 2018-12-08
本文將介紹Php 產生靜態html檔案的三種方法 。1,下面使用模版的一個方法!複製代碼 代碼如下:<?php $fp = fopen ("templets.html","a"); if ($fp){ $fup = fread ($fp,filesize("templets.html")); $fp2 = fopen ("html.shtml","w"); if ($fwrite ($fp2,$fup)){ $fclose ($fp); $fcolse ($fp2); die
Time of Update: 2018-12-08
網路上類似的代碼大多隻能在gb2312編碼下使用,下面這個類同時能在utf-8編碼下將漢字轉換為拼音。具體的代碼和用法如下:複製代碼 代碼如下:<?phpfunction Pinyin($_String, $_Code='gb2312'){$_DataKey = "a|ai|an|ang|ao|ba|bai|ban|bang|bao|bei|ben|beng|bi|bian|biao|bie|bin|bing|bo|bu|ca|cai|can|cang|cao|ce|ceng|cha"."
Time of Update: 2018-12-08
#author:zhxia給php打上php-fpm 補丁sudo tar jxvf php-5.2.14.tar.bz2sudo patch -d php-5.2.14 -p1 < php-5.2.14-fpm-0.5.14.diff編譯phpcd php-5.2.14/sudo ./configure --prefix=/usr/local/php-5.2.14 --with-mcrypt --with-gettext --with-mysql --with-gd
Time of Update: 2018-12-08
1、const用於類成員變數定義,一旦定義且不能改變其值。define定義全域常量,在任何地方都可以訪問。2、define不能在類中定義而const可以。3、const不能在條件陳述式中定義常量複製代碼 代碼如下:if (...) { const FOO = 'BAR'; // invalid } but if (...) { define('FOO', 'BAR'); // valid }
Time of Update: 2018-12-08
所需環境:php 5.3.3apache 2.2.7mysql 5.5.8相關文檔下載:點擊下載解壓Memcached_1.2.5文檔,cmd下執行memcached.exe -d -install將php5.3_vc6_memcachedll文檔解壓,將php_memcache.dll檔案複製到php安裝目錄的ext檔案目錄中。然後在php.ini
Time of Update: 2018-12-08
PHP SESSION原理我們知道,session是在伺服器端保持使用者會話資料的一種方法,對應的cookie是 在用戶端保持使用者資料。HTTP協議是一種無狀態協議,伺服器響應完之後就失去了與瀏覽器的聯絡,最早,Netscape將cookie引入瀏覽器,使得 資料可以用戶端跨頁面交換,那麼伺服器是如何記住眾多使用者的會話資料呢?首先要將用戶端和伺服器端建立一一聯絡,每個客戶
Time of Update: 2018-12-08
如下所示:複製代碼 代碼如下://定義編碼 header( 'Content-Type:text/html;charset=utf-8 '); //Atom header('Content-type: application/atom+xml'); //CSS header('Content-type: text/css'); //Javascript header('Content-type: text/javascript'); //JPEG Image
Time of Update: 2018-12-08
一、通過curl函數複製代碼 代碼如下:$post_data = array();$post_data['clientname'] = "test08";$post_data['clientpasswd'] = "test08";$post_data['submit'] = "submit";$url='http://xxx.xxx.xxx.xx/xx/xxx/top.php';$o="";foreach ($post_data as $k=>$v){ $o.=
Time of Update: 2018-12-08
sql注入: 正常情況下: delete.php?id=3; $sql = 'delete from news where id = '.$_GET['id']; 惡意情況: delete.php?id=3 or 1; $sql = 'delete from news where id = 3 or 1';
Time of Update: 2018-12-08
首先來看看鍵名是string,兩者區別:複製代碼 代碼如下:<?php$arr1 = array('a'=>'PHP');$arr2 = array('a'=>'JAVA');//如果鍵名為字元,且鍵名相同,array_merge()後面數組元素值會覆蓋前面數組元素值print_r(array_merge($arr1,$arr2)); //Array ( [a] => JAVA )//如果鍵名為字元,且鍵名相同,數組相加會將最先出現的值作為結果print_r($arr1+
Time of Update: 2018-12-08
一、PHPAPC安裝下載與解壓安裝包:複製代碼 代碼如下:wget-c http://pecl.php.net/get/APC-3.1.13.tgztar-zvxf APC-3.1.13.tgzcdAPC-3.1.13編譯安裝:複製代碼 代碼如下:wget-c http://pecl.php.net/get/APC-3.1.13.tgz/usr/local/php/bin/phpize./configure--enable-apc --enable-mmap
Time of Update: 2018-12-08
結構模式之間有許多相似之處,因為在物件模型結構中存在幾種關係:類之間的繼承和實現,加上對象組合,這些是PHP設計模式的主要目的。對象組合的最大優勢在於可以在運行時基於配置建立起一個關係,並不用修改實際的代碼,它是類繼承和介面實現需要的一個操作。實際上,你完全可以通過修改對象之間而非類之間的連結定義一個應用程式的功能,這是設計的一部分。結構模式清單 適配器-橋接-外觀(Adapter-Bridge-Facade) 這三個模式的目標是競爭耦合:
Time of Update: 2018-12-08
首先明確一下PHP的輸出順序1.開啟了php輸出緩衝: echo,print -> php output_buffring -> server buffering -> browser buffering -> browser display2.未開啟php輸出緩衝: echo,print -> server buffering -> browser buffering -> browser
Time of Update: 2018-12-08
我覺得我有必要寫這個教程,因為曾經見到的大部分關於自動完成的應用程式都只是給你一個程式源碼包,然後告訴你怎麼使用,而不是告訴你它是如何工作的以及為什麼這樣做。而知道這些可以讓你對這個外掛程式可以進一步的按自己的需求定製。好,我們現在開始。JavaScript代碼 :複製代碼 代碼如下:<script src="jquery-1.2.1.pack.js" type="text/javascript"></script><script
Time of Update: 2018-12-08
首先要安裝好php和apache環境。我用的是wamp整合的套件php 5.2.8apache 2.2.1.1這些都準備好了後,就到 memcache 官網去下載 windows 下的 memcache.exe 這個程式然後把他放在 c:\memcache 目錄下開啟 cmd 命令 輸入cd c:\memcache安裝memcache.exe -p install安裝完成後memcache.exe -p start成功開啟 memcache後就到 php/ext 目錄下 把
Time of Update: 2018-12-08
推薦一個簡單實用的縮放圖片工具 SimpleImage,參考http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/ 使用方法: 設定寬高,不等比例縮放 複製代碼 代碼如下:<?php include('SimpleImage.php'); $image = new SimpleImage(); $image->load('picture.jpg'); $image->resize(250,400)
Time of Update: 2018-12-08
常量可以理解為值不變的變數。常量值被定義後,在指令碼的其他任何地方都不能被改變。一個常量由英文字母、底線、和數字組成,但 數字不能作為首字母出現。在php中使用defaine()函數來定義常量,該函數的文法格式為:define(string constant_name, mixed value, case_sensitive =
Time of Update: 2018-12-08
我們要做一個商品的無限分類首先資料庫欄位為:id ----------商品主鍵idfid ---------- 商品父idname ---------- 商品名最後輸出的數組格式為複製代碼 代碼如下:<PRE class=php name="code"><PRE class=php name="code">array( 0=>array( 'id'=>1, 'fid'=>0, 'name'=>'法國貨' 'child'=>array(
Time of Update: 2018-12-08
1.方法一:複製代碼 代碼如下:<? $dir="D:"; static $dir_list =0; static $file_list =0; function listfile($dir){global $dir_list,$file_list;$d = dir($dir); while ( $entry = $d->read()) { $tem_curnt=$dir."/".$entry; if($entry=="." || $entry=="..") continue;