drogon982007 2018-10-03 13:55
浏览 6

如何在用户点击php中的锚标签时回显?

I want to echo on dynamic url but when I use ? then it is working and when I use / then the url changing but nothing echo out.

<?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>

The line works when I use question mark "?" after kids.php? and the content is also changing:

<a href="http://www.abcd.com/kids.php?<?php echo $pages[$i];?>" <?php echo $pages[$i];?></a>

My problem is that I want to use / instead of question mark ?

  • 写回答

1条回答 默认 最新

  • drkwpgrdb092239314 2018-10-03 14:14
    关注

    You're looking for something that is called pretty URLs.

    For example, if I have the page http://localhost/index.php?user=1 and want to turn it into http://localhost/users/1 you could add these lines to your .htaccess file.

    Options +FollowSymLinks
    RewriteEngine On
    
    RewriteRule ^user/(.*)$ ./index.php?user=$1
    

    This stackoverflow question will most likely help you.

    评论

报告相同问题?

悬赏问题

  • ¥50 切换TabTip键盘的输入法
  • ¥15 关于#网络安全#的问题:求ensp的网络安全,不要步骤要完成版文件
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥20 使用Photon PUN2解决游戏得分同步的问题
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序