| 
       综述:有许多朋友对网站提供繁、简两种版本感到很困惑,是怎么实现的呢?这也是时下众多PHP书籍中被漏掉的一个很重要的知识点。笔者搜集整理并根据自己的开发经验将一些重点与疑点罗列出来与大家共享! 
如何应用繁体中文转换为简体中文的PHP函数: 
	
	- <? 
 
	-  
 
	-  
 
	- function big5togb($code) 
 
	- { 
 
	-  
 
	- include "data_big5.php";  
 
	- $output=""; 
 
	- $length=strlen($code);  
 
	- $code=strtok($code,""); 
 
	- $idx=0; 
 
	- while ($idx < $length) 
 
	- { 
 
	- $tmpStr=$code[$idx].$code[$idx 1]; 
 
	-  
 
	- if (isbig5($tmpStr))  
 
	- { 
 
	- …… 
 
	- } 
 
	- else 
 
	- { 
 
	- $output.= $code[$idx];  
 
	- } 
 
	- $idx ; 
 
	- } 
 
	- return ($output); 
 
	- } 
 
	- ?> 
 
	 
 
如何应用简体中文转换为繁体中文的PHP函数?我们定义一个big5togb的函数来实现这个转换: 
	
	- function gbtobig5($code) 
 
	- { 
 
	- include "data_gb.php";  
 
	- $output=""; 
 
	- $length=strlen($code); 
 
	- $code=strtok($code,""); 
 
	- $idx=0; 
 
	- while ($idx < $length) 
 
	- { 
 
	- $tmpStr=$code[$idx].$code[$idx 1]; 
 
	-  
 
	- if (isgb($tmpStr))  
 
	- { 
 
	- …… 
 
	- } 
 
	- else 
 
	- { 
 
	- $output.= $code[$idx];  
 
	- } 
 
	- $idx ; 
 
	- } 
 
	- return ($output); 
 
	- } 
 
	 
 
在简繁体转换中怎样应用PHP输出控制功能?PHP输出控制功能是怎样一回事? 
PHP的输出信息控制函数可以让你控制你的脚本输出的内容,可以用于许多不同的情况,非凡是在你的脚本已经输出信息后需要发送文件头的情况以及需要对输出信息进行编辑处理的地方。输出控制函数不对使用header()或setcookie()发送的文件头信息产生影响,只对那些类似于echo()、print() 和 PHP 代码的数据块有作用, 
例题控制输出:test.php 
	
	- <? 
 
	- function test($str){ 
 
	- return str_replace("world","php",$str); 
 
	- } 
 
	- ob_start("test"); 
 
	- echo "hello world"; 
 
	- ob_end_flush(); 
 
	- ?> 
 
	 
 
      
      (责任编辑:admin) |