Image

Knowledge base → Variables in php to get the URL or part of it

[Scripts]
Date of publication: 11.10.2023

To obtain URL parameters or individual parts of it, use the following php constructs:

1. Getting a URL

https://domain.tld/temp/url.php



/temp/url.php

2. Getting a folder from a URL

https://domain.tld/temp/url.php



temp

3. Getting the last part of a URL

https://domain.tld/temp/url.php



url.php

3.1 The second option for obtaining the last part of the URL address

https://domain.tld/temp/url.php



url.php

4. Getting the folder where the script is located

https://domain.tld/temp/url.php



/var/www/vhosts/domain.tld/httpdocs/temp

4.1 Getting the root folder

https://domain.tld/temp/url.php



/var/www/vhosts/domain.tld/httpdocs

5. Obtaining a domain name url address

https://domain.tld/temp/url.php



domain.tld

6. Obtaining the IP address of a remote device

https://domain.tld/temp/url.php



xx.ip.xx.ip




No Comments Yet