Home  >  Article  >  Backend Development  >  PHP pseudo-static page function with usage instructions_PHP tutorial

PHP pseudo-static page function with usage instructions_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:51:56726browse

function MakeUrl($arr){ 
          foreach($arr as $key=>$value){ 
                  $url[]=$key."_".$value; 
                  } 
          $tmpurl=implode("_",$url); 
          return $tmpurl.".htm"; 
          } 
function ParseUrl(){ 
     if($_SERVER['PATH_INFO']!=""){ 
          $pathinfo=substr($_SERVER['PATH_INFO'],1); 
          $pathinfo=str_replace(".htm","",$pathinfo); 
          $path=explode("_",$pathinfo); 
          $count=count($path); 
          for($i=0;$i<$count;$i+=2){ 
                  $_GET[$path[$i]]=$path[$i+1]; 
                  } 
                  } 
          } 
//使用实例,链接页面 
$path="http://www.***.com/blog.php/"; 
$path.=MakeUrl(array('BlogID'=>2,'page'=>1)); 
//浏览页面,调用函数ParseUrl();直接可以使用变量$_GET 

如果不想让别人知道你的网站使用PHP程序以达到安全的目的.你可以按照下面的方法配置你的httpd.conf文件
但这并不说明PHP不安全.
你可以使用下面的方法来达到隐藏的目的:
1.将PHP隐藏为其它语言
在你的httpd.conf里任意位置添加下面这一行 
# Make PHP code look like other code types
AddType application/x-httpd-php .asp .py .pl .jsp aspx
2.对 PHP 使用未知扩展名
在你的httpd.conf里任意位置添加下面这一行
# Make PHP code look like unknown types
AddType application/x-httpd-php .bop .foo .133t .los .abc
3.对 PHP 使用 HTML 扩展名
在你的httpd.conf里任意位置添加下面这一行
# Make all PHP code look like html
AddType application/x-httpd-php .htm .html 
重启你的apache.把你的PHP文件名改为上面你所设置的文件后缀名.打开测试吧... 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/319068.htmlTechArticlefunctionMakeUrl($arr){ foreach($arras$key=$value){ $url[]=$key."_".$value; } $tmpurl=implode("_",$url); return$tmpurl.".htm"; } functionParseUrl(){ if($_SERVER['PATH_INFO']!=""){ $p...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn