PHP getsiteurl () function _php Tutorial

Source: Internet
Author: User
Copy CodeThe code is as follows: function Getsiteurl ()
{
Global $_sconfig;

if (Empty ($_sconfig[' Siteallurl '))
{
$uri = $_server[' Request_uri ']?$_server[' Request_uri ']:($_server[' php_self ']?$_server[' php_self ']:$_SERVER[' Script_name ']);
Return Shtmlspecialchars (' http://' $_server[' Http_host '].substr ($uri, 0, Strrpos ($uri, '/') +1));
}
Else
{
Return $_sconfig[' Siteallurl '];
}
}

Global $_sconfig; Defines a global variable $_sconfig ($_sconfig is actually a tuple of VAR, defined in common.php)

if (Empty ($_sconfig[' siteallurl '))//Determine if the $_sconfig[' Siteallurl '] variable is empty

$uri = $_server[' Request_uri ']?$_server[' Request_uri ']:($_server[' php_self ']?$_server[' php_self ']:$_SERVER[' Script_name ']);

$_server[' Request_uri '];$_server[' php_self '];$_server[' Script_name '] after three mesh operation, give the result to the

$_server is also an array, you can print it and know what to do with it. Only three array elements are involved here

$_server[' Request_uri ']; Request_uri:/mysite/-> Site Directory?

$_server[' php_self ']; Php_self:/mysite/index.php-> the file name of the script that is currently executing

$_server[' Script_name ']; Script_name:/mysite/index.php-> contains the path of the current script

http://www.bkjia.com/PHPjc/320518.html www.bkjia.com true http://www.bkjia.com/PHPjc/320518.html techarticle Copy the code as follows: function Getsiteurl () {global $_sconfig; if (Empty ($_sconfig[' Siteallurl ')) {$uri = $_server[' Request_ur I ']?$_server[' Request_uri ']:($_server[' php_self ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.