admin 发表于 2023-2-16 18:55:08

php获取当前页面地址用全局变量$_SERVER

<div id="article_content" class="article_content clearfix">
      <link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/kdoc_html_views-1a98987dfd.css">
      <link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/ck_htmledit_views-6e43165c0a.css">
                <div id="content_views" class="htmledit_views">
                  <p>通过全局变量可以获取41个页面信息&#xff0c;已数组的形式出现</p>
<pre><code>var_dump($_SERVER);</code></pre>
<p>要获取页面的URL地址&#xff0c;可以使用</p>
<pre><code>$url &#61; $_SERVER['REQUEST_URL'];

echo $url; </code></pre>
<p>看看是否是https&#xff0c;是不是443开头&#xff0c;或者off去判断&#xff08;如果是8443需要带上端口号访问&#xff09;</p>
<p></p>
<p>输出完整的url地址</p>
<p></p>
<p> </p>
                </div>
      </div>
      <div id="treeSkill"></div>
页: [1]
查看完整版本: php获取当前页面地址用全局变量$_SERVER