Time of Update: 2016-07-25
有如下問題:讓一個頁面在上開啟,PC上不能直接開啟。例子,php判斷頁面是否由開啟。 $user_agent = $_SERVER['HTTP_USER_AGENT'];if (strpos($user_agent, 'MicroMessenger') === false) { // 非瀏覽器禁止瀏覽 echo "HTTP/1.1 401 Unauthorized";} else { // 瀏覽器,允許訪問 echo "MicroMessenger"; //
Time of Update: 2016-07-25
本代碼實現思路:提供了介面,只要資料格式滿足它所給的介面的XML格式即可以發送給粉絲對應的音樂1,構造提供的XML格式的音樂訊息音樂的XML格式: 12345678 複製代碼寫個函數將資料轉換成這樣的格式,這其中主要資料是MusicUrl和HQMusicUrl裡面的資料,前者普通品質的音樂,後面HQ是高品質的,wifi下會優先播放HQ的。 private function
Time of Update: 2016-07-25
例子,php擷取linux伺服器狀態的代碼。 function get_used_status(){$fp = popen('top -b -n 2 | grep -E "^(Cpu|Mem|Tasks)"',"r");//擷取某一時刻系統cpu和記憶體使用量情況$rs = "";while(!feof($fp)){ $rs .= fread($fp,1024);}pclose($fp);$sys_info = explode("\n",$rs);$tast_info = explode("
Time of Update: 2016-07-25
$xml_data =''.''.'1234567890'.'lgsoftwares'.'mypassword'.'phpmind.com'.''.''.''.''.''.''.'JHM'.'OGGSHE'.'101009'.'101509'.'1'.''.'';$URL = "https://www.abc.com/path/";$ch = curl_init($URL);curl_setopt($ch, CURLOPT_MUTE, 1);curl_setopt($ch,
Time of Update: 2016-07-25
$users = array( array('name' => 'tom', 'age' => 20) , array('name' => 'anny', 'age' => 18) , array('name' => 'jack', 'age' =>
Time of Update: 2016-07-25
$zip = zip_open("20101105.zip");if ($zip) { while ($zip_entry = zip_read($zip)) { echo "Name: " . zip_entry_name($zip_entry) . ""; echo "Actual Filesize: " . zip_entry_filesize($zip_entry) . ""; echo "Compressed Size: " .
Time of Update: 2016-07-25
php的一些輔助函數:mysql_client_encoding()mysql_get_server_info()mysql_get_host_info()mysql_get_client_info()mysql_stat()舉例: $link=mysql_connect("localhost","root","root") or die("couldn't connect:".mysql_error()); echo "字元集的名稱:
Time of Update: 2016-07-25
usage : copy code above into encoder.php place this file into your web server root directory, install all the requried tools needed to use ffmpeg-php now place some video.avi and video.srt or video.sub etc video.idx subtitle ,to encode video with
Time of Update: 2016-07-25
xpath尋找xml節點和節點屬性的值 $xml = " world";function get_data_from_xml($res_data,$node){ $xml = simplexml_load_string($res_data); $result = $xml->xpath($node); while(list( , $node) =
Time of Update: 2016-07-25
php 利用filter 擴充編寫的參數處理類。 http://www.blags.org/php-security-filter-function/ exp: 首先引入檔案 include 'filter.php' $email = CFilter::Email($_POST['email']); 驗證成功返回字串,反之返回false。 /
Time of Update: 2016-07-25
仿寫elFinder的,抽出關鍵的成員方法做的一個簡單樣本 實現功能是: 實現多檔案複製或移動操作 註:為了方便測試,對一些判斷做了簡單處理。並且會在程式檔案所在目錄下 新產生一個test檔案夾作為目的檔案夾。如果實際使用需要修改。 ?/** * 複製/移動操作簡單樣本 : >PHP5 * *//** *
Time of Update: 2016-07-25
自己練習寫的資料庫操作基類,包含最基本的CURD操作.可整合到架構內. // 設定檔$db = array('host'=>'localhost','user'=>'root','password'=>'','database'=>'test',)?>//php 類class db {public $conn;public static $sql;public
Time of Update: 2016-07-25
public function fooAction(){ // forward to another action in the current controller and module: $this->_forward('bar', null, null, array('baz' => 'bogus'));}public function barAction(){ // forward to an action in another controller,
Time of Update: 2016-07-25
session_start();//產生驗證碼圖片Header("Content-type: image/PNG");srand((double)microtime()*1000000);$im = imagecreate(62,20);$black = ImageColorAllocate($im, 69,120,239);$white = ImageColorAllocate($im, 0,0,0);$gray = ImageColorAllocate($im,
Time of Update: 2016-07-25
在php的項目過程中老是出現這個提示,起初是用$act來接受表單post過來的資料:$act=$_POST['act'];在php的項目過程中老是出現這個提示,起初是用$act來接受表單post過來的資料:$act=$_POST['act'];用以上代碼總是提示:Notice: Undefined index: act in F:\windsflybook\post.php on line 18另外,有時還會出現:Notice: Undefined variable: Submit ......
Time of Update: 2016-07-25
從網上找的,讀取檔案,改變索引值對的方法。 package com.sdut.edu.tools;import
Time of Update: 2016-07-25
//----------------------------------------------------//函數名:csubstr//作 用:截字串,漢字一個算兩個字元,英文算一個字元//針對GBK(GB2312)編碼的網站//參 數:$str ----原字串// $start ----開始長度// $len ----截取長度//傳回值:截取後的字串//整理人:itlearner//-------------------------------------
Time of Update: 2016-07-25
友言 Uyan 是第三方評論、留言外掛程式。 讓使用者可以通過QQ、微薄等帳號發布評論和留言。 在 羊駝!CMS 中整和 Uyan 方法如下。 以建立友言留言板為例。 0. 訪問 http://uyan.cc/getcode 複製友言代碼 1. 點擊 後台 -> 排版 -> 添加排版 2. 輸入 名稱 ->留言板 代碼 -> 粘帖友言代碼 儲存 3. 點擊 後台-> 內容 -> 添加頁面 4. 輸入 標題 -> 留言板
Time of Update: 2016-07-25
php 簡訊介面,基本上解決 了,php調用簡訊介面出現的亂碼問題,代碼並不複雜,但還是實用的. 以下簡訊介面支援長簡訊,支援回複,在這裡,我只把發送的功能分享一下,有需要的朋友,可以參考一下56簡訊網 網址是:http://www.56dxw.com 速度挺不錯的哦. reg.php
Time of Update: 2016-07-25
/** * 操縱檔案類 * * 例子: * FileUtil::createDir('a/1/2/3'); 測試建立檔案夾 建一個a/1/2/3檔案夾 * FileUtil::createFile('b/1/2/3'); 測試建立檔案 在b/1/2/檔案夾下面建一個3檔案 * FileUtil::createFile('b/1/2/3.exe'); 測試建立檔案