WML處理---H_wml.php

來源:互聯網
上載者:User
 H_encod = "gb2312";//設定字元編碼(wap頁的編碼)$H_wml -> H_head();//設定頭資訊$H_wml -> H_nocah();//無緩衝(是否緩衝)需要緩衝則不需要寫該行$H_wml -> H_card("cd1","葉綠輝香");//設定card標籤$H_wml -> H_img("image/logo.wbmp","Logo");//設定圖片(圖片路徑,注釋)$H_wml -> H_br();//換行$H_wml -> H_link("index.php","去首頁");//超連結(串連地址,文字)$H_wml -> H_str(" ");//空格$H_wml -> H_br();//換行$H_wml -> H_str("QQ:273642232;Email:yin273642232@163.com");//字串$H_wml -> H_disp();//顯示*************************************///Start Classclass H_wml{public $H_debug = false;public $H_desce;//描述public $H_ROOT_DIR;//檔案地址路徑public $H_str;//字元public $H_encod;//字元編碼public $H_bqi=0;public $H_gbary;public function __construct(){//當執行個體化一個對象的時候,這個對象的這個方法首先被調用return ''; } public function __destruct(){ //當刪除一個對象或對象操作終止的時候,調用該方法 return ''; } public function __get($key){ //當試圖讀取一個並不存在的屬性的時候被調用  return '['.$key.'] Variable not find';  }  public function __set($key,$val){ //當試圖向一個並不存在的屬性寫入值的時候被調用  return '['.$key.'] Variable not find';  }  public function __call($key,$args){  //當試圖調用一個對象並不存在的方法時,調用該方法  return '['.$key.'] Function not find';}public function __toString(){//當列印一個對象的時候被調用return $this -> H_desce();  }  public function __clone(){  //當對象被複製時,被調用  return "clone";  }public function H_desce(){//返回描述$this -> H_desce .= '類名:H_wml-WML處理;';$this -> H_desce .= '函數:H_head(),返回:這是wml頭部,參數:無;';$this -> H_desce .= '函數:H_endbq($val),返回:記錄結束標籤,參數:$val-被記錄的標籤;';$this -> H_desce .= '函數:H_card($id,$title),返回:設定卡片,參數:$id-該卡片的id.$title-該卡片的title;';$this -> H_desce .= '函數:H_nocah(),返回:設定緩衝,參數:無;';$this -> H_desce .= '函數:H_p($str,$align="left"),返回:設定一行,參數:$str-改行字串.$align-顯示模式(預設居左 left);';$this -> H_desce .= '函數:H_link($link,$str),返回:設定串連,參數:$link-串連地址.$str串連字元;';$this -> H_desce .= '函數:H_img($src,$alt),返回:設定圖片,參數:$src-圖片檔案路徑.$alt-圖片描述;';$this -> H_desce .= '函數:H_input($name,$type="text",$format="",$maxlength="10",$emptyok="false"),返回:設定輸入框,參數:$name-名字.$type-類型(預設text).$format-格式,$maxlength-最大長度.$emptyok-是否記錄(預設不記錄);';$this -> H_desce .= '函數:H_br(),返回:設定換行,參數:無;';$this -> H_desce .= '函數:H_str($str),返回:設定字元,參數:$str-字串;';$this -> H_desce .= '函數:H_disp(),返回:輸出資訊(wml內容),參數:無;';return $this -> H_desce;}public function H_head(){//設定頭資訊$this -> H_gbary="";$this -> H_bqi = 0;$H_head = header('Content-type:text/vnd.wap.wml'.($this -> H_encod == '' ? '' : ';charset='.$this -> H_encod));$H_head .= "\n";$H_head .= " H_encod == '' ? '' : ' encoding="'.$this -> H_encod.'"')."?>";$H_head .= "\n";$H_head .= '';$H_head .= "\n";$H_head .= '';$H_head .= "\n";$this -> H_endbq('');$this -> H_str = $H_head;return true;}public function H_endbq($val){$this -> H_gbary[$this -> H_bqi] = $val;++$this -> H_bqi;return true;}public function H_card($id,$title){//設定卡片$H_card = "";$H_card .= "\n";$this -> H_endbq('');$this -> H_str .= $H_card;return true;}public function H_nocah(){//設定緩衝$H_nocah = "";$H_nocah .= "\n";$this -> H_str .= $H_nocah;return true;}public function H_p($str,$align="left"){//設定一行$H_p = "

".$str.'

';$H_p .= "\n";$this -> H_str .= $H_p;return true;}public function H_link($link,$str){//設定串連$H_link = "".$str."";$H_link .= "\n";$this -> H_str .= $H_link;return true;}public function H_img($src,$alt){//設定圖片$H_img = '';$H_img .= "\n";$this -> H_str .= $H_img;return true;}public function H_input($name,$type="text",$format="",$maxlength="10",$emptyok="false"){//設定輸入框 $H_input = ''; $H_input .= "\n"; $this -> H_str .= $H_img; return true; } public function H_br(){ //設定換行 $this -> H_str .= '
'; return true; } public function H_str($str){ //設定字元 $this -> H_str .= $str; return true; }public function H_disp(){//輸出資訊while($this -> H_bqi > 0){$val .= "\n".$this -> H_gbary[$this -> H_bqi -1 ];--$this -> H_bqi;}echo $this -> H_str.$val;return true;}public function text2wml($content){ // 將 WML 變數首碼"$"轉義 $content = str_replace('$', '$$', $content); // 轉換特殊字元,並將 Windows/DOS 分行符號(\r\n)轉化為 Unix 分行符號(\n) $content = str_replace("\r\n", "\n", htmlspecialchars($content)); // 通過分行符號來將各行分開進行處理(過濾空行) $content = explode("\n", $content); for ($i = 0; $i < count($content); $i++) { // 過濾首尾空格 $content[$i] = trim($content[$i]); // 如果去掉全形空格為空白行,則設為空白行,否則不對全形空格過濾。 if (str_replace(" ", "", $content[$i]) == "") $content[$i] = ""; } //合并各行,轉化為 WML,並過濾掉空行 $content = str_replace("


\n", "", implode("

\n

", $content)."\n"); return $content; } public function html2wml($content,$H_p="",$H_str=""){ // 過濾掉樣式表和指令碼 $content = preg_replace("/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.