如何获取 php 中的导航菜单项?

How can I get the navigation menu item in php?

我用 bootstrap 创建了一个导航栏。我想用 PHP 代码获取导航菜单项名称。我试图用 'GET' 方法来做到这一点,但如果不更改页面我就无法做到这一点。我在这里附上了导航栏代码。

<body>

    <!--  ======================== Navigation Bar ==============================  -->

    <section id="nav-bar">

        <nav class="navbar navbar-expand-lg navbar-light static-top">
            <div class="container-fluid p-0" id="navbarSupportedContent">
                
                <a class="navbar-brand" href="#"><img src="../images/logo.png"/></a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive"
                    aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarResponsive">
                    <ul class="navbar-nav ml-auto">
                    <div class="hori-selector"><div class="left"></div><div class="right"></div></div>
                        <li class="nav-item active">
                            <a class="nav-link" href="#">Home</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">Gallery</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">Contact</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">About</a>
                        </li>
                    </ul>
                </div>

            </div>
        </nav>
    </section>

    <?php 

        echo "Selected Item"; // display selected navigation item here.

    ?>

</body>

</html>

这是我的 index.php 页面正文。我想在同一 index.php 页面上获取所选项目的名称。请问有人能帮帮我吗?

我用 JavaScript 和 Ajax 解决了这个问题