用户单击php中的锚标记时如何回显?

时间:2018-10-03 13:55:07

标签: php

我想在动态网址上回显,但是当我使用时?则它可以正常工作,当我使用/时,URL会发生变化,但没有任何回声。

GetSpace - Next ${__jm__Next Thread Group(GetSpace)__idx} items

当我使用问号“?”时,该行有效在kids.php之后?而且内容也在变化:

<?php
 $pages = array("story1", "story2", "story3", "story4");

 if(isset($_GET['stroy2'])) { 
      echo "You are reading Story 2!";
 }

 if(isset($_GET['stroy3'])) {
      echo "You are reading Story 3!";
 }
 ?>

<html>
<body>
  <form action="kids.php" method="post">

    // $i=2; here and below line is not working. This is the problem.
     <a href="http://www.abcd.com/kids.php/<?php echo $pages[$i];?>" <?php echo $pages[$i];?></a>
  </form> 
 </body>
 </html>

我的问题是我想使用/而不是问号?

1 个答案:

答案 0 :(得分:3)

您要查找的是漂亮的网址。

例如,如果我有页面http://localhost/index.php?user=1,并且想要将其转换为http://localhost/users/1,则可以将这些行添加到.htaccess文件中。

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^user/(.*)$ ./index.php?user=$1

This stackoverflow question很可能会为您提供帮助。