Time of Update: 2017-01-13
代碼如下複製代碼 index.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><
Time of Update: 2017-01-13
例子一 代碼如下複製代碼 //判斷遠程檔案 function check_remote_file_exists($url) { $curl = curl_init($url); // 不取回資料 curl_setopt($curl, CURLOPT_NOBODY, true); // 發送請求 $result = curl_exec($curl); $found = false; // 如果請求沒有發送失敗 if ($result !== false) { //
Time of Update: 2017-01-13
reset (PHP 3, PHP 4, PHP 5)函數定義 mixed reset ( array &array )作用:該函數將 array 的內部指標倒回到第一個單元並返回第一個數組單元的值,如果數組為空白則返回 FALSE。例如: 代碼如下複製代碼 <?php$array=array('step one','step two','step three','step four');echo reset($array); //輸出:step
Time of Update: 2017-01-13
例子 代碼如下複製代碼 function Bing_string_cleanr( $string ){ $string = trim( $string ); $string = strip_tags( $string ); $string = htmlspecialchars( $string, ENT_QUOTES, 'UTF-8' ); $string = str_replace( "n",
Time of Update: 2017-01-13
首頁 index.php: 代碼如下複製代碼 <!DOCTYPE html><html><head><meta name="author" content="flute" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>
Time of Update: 2017-01-13
html: 代碼如下複製代碼 <form action=”insertPic.php” method=”post” enctype=”multipart/form-data” name=”mainForm” id=”mainForm”><input type=”file”
Time of Update: 2017-01-13
此處所指的nbsp是實體,而不是nbsp四個字元 代碼如下複製代碼 $str = " abc"; $converted = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES)));var_dump($converted); // 這兒才是要處理的字串,上面的都是準備工作
Time of Update: 2017-01-13
一,一維數組增加元素$ArrayList = ArrayListay(); Array_push($ArrayList, el1, el2 ... eln); 但其實有一種更直接方便的做法: 代碼如下複製代碼 $ArrayList = ArrayListay(); $ArrayList[] = el1; $ArrayList[] = el2; ... $ArrayList[] = eln;
Time of Update: 2017-01-13
1.array_merge()合并例子 代碼如下複製代碼 $array = array('a'=>'bb');$array2 = array('b'=>'cc');$array3 = array_merge($array,$array2);輸出結果為Array ( [a] => bb [b] => cc ) 上面因為都是數組就沒有問題了,假如我們把$array 設定不是數組看看什麼情況 代碼如下複製代碼 $array = 1;//
Time of Update: 2017-01-13
PHP方法:利用PHP的“_SERVER ”數組“HTTP_USER_AGENT”項,擷取該頁面的使用者代理程式的資訊,來完成這個工作。 代碼如下複製代碼 <?phpecho $_SERVER["HTTP_USER_AGENT"];?> 【winows/chrome】 輸出結果:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36
Time of Update: 2017-01-13
以前使用Google提供了較為完善的二維碼產生介面,調用API介面很簡單,但是現在由於訪問google出現問題,需要使用其他的方法產生二維碼。PHP QR Code是一個PHP二維碼產生類庫,利用它可以輕鬆產生二維碼,官網提供了下載和多個示範demo,官網地址:http://phpqrcode.sourceforge.net下載官網提供的類庫後,只需要使用phpqrcode.php就可以產生二維碼了,當然您的PHP環境必須開啟支援GD2。 ‘’qrlib.php
Time of Update: 2017-01-13
例子 代碼如下複製代碼 <?php //刪除目錄下所有空目錄 array_map('rmdir', glob('*', GLOB_ONLYDIR)); //刪除目錄所有檔案 array_map('unlink', array_filter(glob('*'), 'is_file'));?> 原理分析array_map('rmdir', glob('*',
Time of Update: 2017-01-13
首先要記住json_encode返回的是字串, 而json_decode返回的是對象.判斷資料不是JSON格式: 代碼如下複製代碼 function is_not_json($str){ return is_null(json_decode($str));} 判斷資料是合法的json資料: (PHP版本大於5.3) 代碼如下複製代碼 function is_json($string)
Time of Update: 2017-01-13
這個是借力打力,只是抓去朋友網的內容!!!不過相當好用哦!看代碼: 代碼如下複製代碼 <?php$videourl='http://v.youku.com/v_show/id_XMjA5MjQ0OTQ0.html';function get_content($url ,$data){ if(is_array($data)){ $data = http_build_query($data, '', '&');
Time of Update: 2017-01-13
例子 代碼如下複製代碼 <?phpsession_start();if(empty($_SESSION['ip']))//第一次寫入操作,判斷是否記錄了IP地址,以此知道是否要寫入資料庫{$_SESSION['ip']=$_SERVER['REMOTE_ADDR'];//第一次寫入,為後面重新整理或後退的判斷做個鋪墊...........//寫入資料庫操作}else//已經有第一次寫入後的操作,也就不再寫入資料庫{echo
Time of Update: 2017-01-13
前期需要瞭解的知識點move_uploaded_file()檔案上傳函數 代碼如下複製代碼 if(move_uploaded_file($_FILES["filename"]["tmp_name"]){echo '檔案上傳成功';} $_FILES php全域變數$_FILES: 經由 HTTP POST 檔案上傳而提交至指令碼的變數。類似於舊數組 $HTTP_POST_FILES 數組(依然有效,但反對使用)
Time of Update: 2017-01-13
例子。explode 代碼如下複製代碼 function checkstr($str){ $needle = "b";//判斷是否包含a這個字元 $tmparray = explode($needle,$str); if(count($tmparray)>1){ return true; } else{ return false;
Time of Update: 2017-01-13
使用PHP的GD庫擴充類製作驗證碼的基本步驟:啟用php.ini設定檔中的extension=php_gd2.dll擴充(開啟php.ini設定檔,去掉行首的分號後重啟Apache即可);下面是PHP產生驗證碼的代碼: 代碼如下複製代碼 <?phpfor($i=0;$i<5;$i++){
Time of Update: 2017-01-13
PHP glob函數的使用:glob — 尋找與模式比對的檔案路徑例子 代碼如下複製代碼 <?php$fileList=glob('*.*');for ($i=0; $i<count($fileList); $i++) {echo $fileList[$i].'<br />';}$fileList2=glob('images/*');for ($i=0; $i<count($fileList2); $i++) {echo
Time of Update: 2017-01-13
ubuntu下預設是沒有php語法錯誤提示的,如果要開啟,需要修改幾個地方:1. 開啟php.ini檔案。這個檔案在: /etc/php5/apache2 目錄下,需要修改這個檔案的許可權才能寫入。 sudochmod777/etc/php5/apache2/php.ini2. 搜尋並修改下行,把Off值改成On display_errors=Off3. 搜尋下行