php如何在命令行中传递一个锚点

I need to pass parameters and an anchor in a php program to make sure the cursor is positioned at the last place it was in the page when it returns.

program.php?ID=123&ID2=456#777

ID=123

ID2=456

html anchor is #777

Can someone tell me how to make this work? Since it isn't working the way I'm doing it now. Thanks

The browser will not send the anchor to web server.

So PHP can't get the anchor from url.

maybe you can use javascript to request program.php?ID=123&ID2=456&anchor=777, then you can get the anchor by $_GET['anchor'].

Sorry for my bad english (ㄒoㄒ).


If you want force the cursor to the position.

this code will redirect to http://website.com/page.php#anchor and the broswer will auto cursor the position.

<?php
header("location: http://website.com/page.php#anchor");
exit;

warning: take care about header function, there is the manual header function

If the current page is the same as the redirect page, above the code will infinite redirect and the browser will throw error. So you have to write some logic, make it redirect when you want. Or just write two different page, one to show content, other one redirect to content page with anchor.

But I still think it is better to do that by JavaScript.