PHP如何對(duì)中文進(jìn)行轉(zhuǎn)義?

發(fā)布時(shí)間:2024-01-24
php如何對(duì)中文進(jìn)行轉(zhuǎn)義?
在php中可以通過(guò)使用“urlencode()”函數(shù)將中文進(jìn)行轉(zhuǎn)義,該函數(shù)的作用是對(duì)url字符串進(jìn)行編碼,其語(yǔ)法為“urlencode($str )”,使用時(shí)將中文傳入即可。
使用示例
<?phpecho '<a href="mycgi?foo=', urlencode($userinput), '">';?><?phpfunction fullescape($in){ $out = ''; for ($i=0;$i<strlen($in);$i ) { $hex = dechex(ord($in[$i])); if ($hex=='') $out = $out.urlencode($in[$i]); else $out = $out .'%'.((strlen($hex)==1) ? ('0'.strtoupper($hex)):(strtoupper($hex))); } $out = str_replace(' ',' ',$out); $out = str_replace('_','_',$out); $out = str_replace('.','.',$out); $out = str_replace('-','-',$out); return $out;}?><?php function flash_encode ($input) { return rawurlencode(utf8_encode($input)); }?>... could do the problem. unfortunately flash still have problems with read some quotations, but with this one:<?php function flash_encode($string) { $string = rawurlencode(utf8_encode($string)); $string = str_replace("?", "-", $string); $string = str_replace("?", "'", $string); $string = str_replace("?", "'", $string); $string = str_replace("?", "'", $string); $string = str_replace("?", "", $string); $string = str_replace("?", "", $string); $string = str_replace("?", "", $string); $string = str_replace("?", "?", $string); $string = str_replace("?", "?", $string); return $string; }?>推薦教程:《php》
上一個(gè):分子標(biāo)記技術(shù)在茶樹(shù)研究中的應(yīng)用
下一個(gè):普洱茶的茶票和內(nèi)票,你分得清楚么?

RC-01U8R20FTE在線查庫(kù)存,今日?qǐng)?bào)價(jià)
現(xiàn)金支票背面是否要蓋章,現(xiàn)金支票的簽發(fā)流程
多雨季節(jié)別讓月季染病
RC0201DR-07464RL,0201 464Ω 0.5% 1/20W 電阻
值得一看,為什么要說(shuō)高山雨霧出好茶?
win7系統(tǒng)c盤(pán)紅了怎么解決(windows7c盤(pán)紅了)
景東的歷史貢獻(xiàn)
手機(jī)鍵盤(pán)變小了怎么變回去(手機(jī)鍵盤(pán)變小了咋辦)
LR2512-21R0014F4,旺詮合金2512 1.4mΩ ±1% 1W
拘留的期限是多久
十八禁 网站在线观看免费视频_2020av天堂网_一 级 黄 色 片免费网站_绝顶高潮合集Videos