PHP解析地址栏以转发到特定内容

My webpage (www.gagandipsingh.com) is coded mostly on one page, with links calling the following script, which show/hide certain div sections...

    <script type="text/javascript">
    function show() {
        document.getElementById(arguments[0]).style.display='block';
        for (var i = 1; i < arguments.length; i++) {
            // alert(arguments[i]);
             document.getElementById(arguments[i]).style.display='none';
        }
        return false;
    } 
</script>

My question is, is it possible to parse the address bar so that a certain div may be shown/hidden? I found i could get variables (ex: gagandipsingh.com?p=code) so I attempted my requirment with the following...

<?php 
    echo '<script type="text/javascript" src="show_hide.js"></script>';
    if (isset($_GET['p'])) 
    { 
        $page = $_GET['p'];
        if ($page == 'code'){
            echo "show('Code','Media','Home', 'Resume','Contact')";
        }
    } 
    else 
    { 
        echo "Variable not set."; 
    } 
?>

which did not work; the function never gets called, just prints that message. You can see an example of that at http://gagandipsingh.com/test/?p=code

Any advice would be greatly appreciated.

If you want the function call to be executed instead of just being displayed as part of the web page, you have to enclose it in a <script> tag.

<?php 
    echo '<script type="text/javascript" src="show_hide.js"></script>';
    if (isset($_GET['p'])) 
    { 
        $page = $_GET['p'];
        if ($page == 'code'){
            echo "<script type='text/javascript'>show('Code','Media','Home', 'Resume','Contact');</script>";
        }
    } 
    else 
    { 
        echo "Variable not set."; 
    } 
?>

Check this file http://gagandipsingh.com/test/show_hide.js

1.Why this contain <script type = "text/javascript"> and this </script> in JS file.

Maybe your code like this

<?php 
    echo '<script type="text/javascript" src="show_hide.js"></script>';
    if (isset($_GET['p'])) 
    { 
        $page = $_GET['p'];
        if ($page == 'code'){
            echo'<script type="text/javascript">';
            echo "show('Code','Media','Home', 'Resume','Contact')";
            echo'</script>';
        }
    } 
    else 
    { 
        echo "Variable not set."; 
    } 
?>