ホームページ  >  記事  >  バックエンド開発  >  PATH_INFO関数を使いたい。しかし、どこに追加すればよいかわかりませんか?解決

PATH_INFO関数を使いたい。しかし、どこに追加すればよいかわかりませんか?解決

WBOY
WBOYオリジナル
2016-06-13 13:34:57719ブラウズ

想用PATH_INFO功能。但是不知道应该加到哪里?
这是一个查看网页源代码的功能
网址是这样的
www.vipcha.net/5/
我想实现的功能是这样的
www.vipcha.net/5/www.baidu.com //在原来的基础上增加一个网址。


代码如下: 请高手指点一下。谢谢

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><?php
$hu = 'yuan';
@require_once('global.php');
$domain = $_POST['domain'];
if($domain){
    is_domain($domain) or exit( "<script language=javascript>alert('请输入正确的域名!');location.href='index.php';</script>");
    $content = @file_get_contents("http://".$domain);
    @require_once('cache.php');
    if(file_exists("cache/cache.php")){
        @require_once("cache/cache.php");
        $urls = filehave($urls,$domain);
    }else{
        $urls = fileno($domain);
    }
    writeover("cache/cache.php","<?php\r\n\$urls=".vvar_export($urls).";\r\n?>");
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>网页源代码查看器</title>
<form id="f" action="" method="POST">
<input name="domain" type="text" id="domain" class="input" size="40" url="true" value="<?php echo $domain?>"/>
<input name="btnS" class="but" type="submit" value="查询"  id="sub"/> </form>


<textarea id="content" name="content" style="width:750px;height:850px;border:1px solid #c5e2f2;overflow:visible;" cols="20" rows="65"><?php echo $content;?></textarea></div>


最近查询
<table>
<tr><td align="left" style= "word-wrap:break-word;word-break:break-all">
<?php
@require_once('cache/cache.php');
if($urls){
foreach ($urls as $key=>$v){
    echo "<a href=http://www.vipcha.net/5/".$urls[$key]." target=_blank>".$urls[$key]."</a>  ";
}}?></td></tr>
</table> 


------解决方案--------------------
表单不要提交

用js跳转

服务器接受参数,启用rewrite
------解决方案--------------------
PHP code

<?php
//在哪都能加
$path_parts = pathinfo($_SERVER['REQUEST_URI']);
print_r($path_parts);
?>
<br><font color="#e78608">------解决方案--------------------</font><br>网址是这样的 www.vipcha.net/5/<br>那么你实际访问的是 www.vipcha.net/5/index.php<br>如果那个 5/ 适当做参数时 那要这样才行 www.vipcha.net/index.php/5<br>这就是 PATH_INFO<br><br>我想实现的功能是这样的<br>www.vipcha.net/5/www.baidu.com<br>这就需要 urlrewrite 了,因为需要隐藏php文件名<br> <div class="clear">
                 
              
              
        
            </div>
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。