Time of Update: 2016-07-29
複製代碼 代碼如下:class MyFramework_Soap_server extends Zend_Soap_Server { protected $_login = ''; protected $_password = ''; public function __construct($wsdl = null, array $options = null) { parent::__construct($wsdl,$options); if(isset($options['login']))
Time of Update: 2016-07-29
首先解釋賦值操作符=的行為,看下面的例子: 複製代碼 代碼如下:$i = 0; $j = $i; $j = 0; echo $j; // 列印輸出0 $arr = array(0); $arr2 = $arr; $arr2[0] = 1; echo $arr[0]; //列印輸出0 class B { public $i = 0; } $b = new B(); $c = $b; $c->i = 1; echo($b->i); // 列印輸出1
Time of Update: 2016-07-29
複製代碼 代碼如下:function ImageResize($srcFile,$toW,$toH,$toFile="") { if($toFile==""){ $toFile = $srcFile; } $info = ""; $data = GetImageSize($srcFile,$info); switch ($data[2]) { case 1: if(!function_exists("imagecreatefromgif")){ echo
Time of Update: 2016-07-29
先用一段代碼重現一下問題 乍一看,結果很讓人費解: 複製代碼 代碼如下:$string = hello world EOF; $data = simplexml_load_string($string); print_r($data); print_r($data->foo); ?> 乍一看,結果很讓人費解: 複製代碼 代碼如下:SimpleXMLElement Object ( [foo] => Array ( [0] => SimpleXMLElement Object ( [bar]
Time of Update: 2016-07-29
mysql_set_charset()。 這個函數是這樣用的: mysql_set_charset('utf8', $link); 成功返回 TRUE,失敗返回 FALSE。 就這麼簡單。 下面是PHP手冊原文 This is the preferred way to change the charset. Using mysql_query() to execute SET NAMES .. is not recommended.
Time of Update: 2016-07-29
迴圈建立目錄方法 這個會產生image.gif目錄 複製代碼 代碼如下:$filepath = "test/upload/2010/image.gif"; mk_dir($filepath); // 迴圈建立目錄 function mk_dir($dir, $mode = 0755) { if (is_dir($dir) || @mkdir($dir,$mode)) return true; if (!mk_dir(dirname($dir),$mode)) return false;
Time of Update: 2016-07-29
xml.class.php檔案代碼複製代碼 代碼如下:* example 讀取資料: * * $xml = new xml("dbase.xml",'table'); * * $data=$xml->xml_fetch_array(); * * echo ""; * * print_r($data); * class xml { var $dbase; //資料庫,要讀取的XML檔案 var $dbname; //資料庫名稱,頂層元素,與資料庫檔案名稱一致 var $dbtable;
Time of Update: 2016-07-29
第一個檔案login_frm.php這個是登入視窗 代碼 複製代碼 代碼如下: 第二個檔案login.php這個是處理登入複製代碼 代碼如下:if($_POST['username'] = 'admin') { setcookie('haha','gogo'); header("location:index.php"); } ?> 第三個檔案index.php再看下效果 複製代碼 代碼如下:if($_COOKIE['haha'] == 'gogogo') { echo
Time of Update: 2016-07-29
1.根據get判斷,擷取get產生css 複製代碼 代碼如下: 2.點擊的時候,就可以開啟連結 複製代碼 代碼如下: 北京 include_once ("config/db.inc.php"); $recuit_city_select = "select * from cdb_plugins_city where city_id in(13,14,15,16)"; $recuit_city_query = mysql_query ( $recuit_city_select ); while (
Time of Update: 2016-07-29
我們草根站長購買的虛擬機器主機往往都有檔案數量限制,大量小檔案佔用大量資源,落伍精華區也有兄弟推薦豆瓣的解決方案,但是要有主機許可權。只能另裝思路,採用php+SQLite解決問題,經過我測試,切實可行,現在推薦給大家。 現在公開代碼: 建立資料庫檔案:php1.php 複製代碼 代碼如下:$db = new SQLite3('mysqlitedb.db'); //擷取檔案2進位流 $filename = "http://www.jb51.net/logo.gif"; $handle =
Time of Update: 2016-07-29
下面列出幾個比較常用的方法: 首先介紹一下所涉及的資料表結構,四個欄位: 複製代碼 代碼如下:uid :使用者id session_id :使用者登入後系統產生的session_id,PHP可是使用session_id()函數擷取 login_time :登入時間 logout_time :登出時間 1. 用戶端定時發送請求到伺服器端。實現方法是在使用者登入後,將uid,session_id,login_time插入一條記錄,然後在用戶端js設定一個計時器,比如每10分鐘向伺服器端發送一個請求,
Time of Update: 2016-07-29
有同學問了一個問題: 複製代碼 代碼如下:for($i = 'A'; $i echo $i; } //輸出是啥? 輸出是: 複製代碼 代碼如下:ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARAS……. 為啥? 其實很簡單, PHP的手冊中也有說明, 只不過恐怕很多人不會一章一節的把手冊仔細閱讀一遍: 複製代碼 代碼如下:PHP follows Perl's convention when dealing with
Time of Update: 2016-07-29
使用說明: //載入函式 include_once('phpCodeZip.php'); //建立加密檔案(sourceDir要加密的php檔案目錄,targetDir加密後的檔案目錄) $encryption = new PhoCodeZip('sourceDir','targetDir'); //執行行加密 $encryption->zip(); phpCodeZip.php源碼下載 phpCodeZip.rar phpCodeZip.php源碼內容 複製代碼 代碼如下:/* *
Time of Update: 2016-07-29
下載地址:http://www.codeplex.com/PHPExcel 下面是總結的幾個使用方法 include ‘PHPExcel.php'; include ‘PHPExcel/Writer/Excel2007.php'; //或者include ‘PHPExcel/Writer/Excel5.php'; 用於輸出.xls的 建立一個excel $objPHPExcel = new PHPExcel(); 儲存excel—2007格式
Time of Update: 2016-07-29
先來說說兩種方式: 1)定義一個字串變數,裡面儲存要載入的檔案清單。然後foreach載入。複製代碼 代碼如下:$a = '/a.class.php;/Util/b.class.php;/Util/c.class.php'; $b = '/d.php;/e.class.php;/f.class.php;/g.class.php'; // 載入基本系統檔案 $kernel_require_files = explode(';', $a);//SYS_REQUIRE_LIB_FILE_LIST);
Time of Update: 2016-07-29
第一種方法:如果不影響程式的正常執行,可以採用屏蔽的方法可以在代碼的第一行 加上 error_reporting(E_ALL ^ E_NOTICE); 關閉掉 NOTICE錯誤的警告第二種方法:定位到具體的行,根據提示解決。例如elseif ($_POST['istrue'] == 'ok'),如上代碼,沒有提交istrue這個,所以肯定是有問題的。可以用如下代碼解決上面先判斷複製代碼 代碼如下:if(array_key_exists( 'istrue',$_POST)) {
Time of Update: 2016-07-29
複製代碼 代碼如下:/* * ————————————————- * @file : 5.php * @function : arr2str * @copyright : 2002-2009 Xingmo Inc * @author : Fanglor * @date : 2010-06-25 * @update : * ————————————————- */ $fruits = array ( "fruits" => array("a" => "orange", "b" =>
Time of Update: 2016-07-29
php面試題說明 : 例如:my name is fanglor =》 ym eman si orlgnaf php面試題的答案: 複製代碼 代碼如下:function restr ($str) { $str1 = explode (' ',$str); $str2 = ''; $temp = ''; for ($i=0;$i{ $str2 .= $temp.strrev ($str1[$i]); $temp = ' '; } return $str2; } 測試代碼: 複製代碼
Time of Update: 2016-07-29
複製代碼 代碼如下:/*—————————————————— */ //– 遞迴實現無限分類產生下拉式清單函數 //– $tpl->assign('sort_list',createSortOptions ()); //– $tpl->assign('sort_list',createSortOptions ($sort_id)); /*—————————————————— */ function createSortOptions ($selected=0,$parent_id=0,$n=-1
Time of Update: 2016-07-29
目錄下必須有default.gif(此圖為模板縮圖)的才為合法的模板 複製代碼 代碼如下:function get_template () { $template = array (); $dir = CMS_ROOT.'/tpl/'; $n = 0; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ($file =='.' or $file == '..'