How to Get Domain Name from URL in PHP Parse domain name from URL is used in many cases in the web project. In this short tutorial, we’ll provide a simple code snippet to get domain name from URL in PHP. Using our example script, you’ll be able to extract only the domain name from any type of URL. All PHP code are group together in getDomain() function. The $url param should be passed to getDomain() function, from which you want to get the domain name. getDomain() function returns
undefined
Get current Domain URL in PHP I have my site on server http://www.myserver.uk.com For this i have two domain: http://one.com and http://two.com i would like get with PHP current domain, but if I use $_SERVER['HTTP_HOST'] then this show me myserver.uk.com instead of: one.com or two.com How can i get domain, not the server name? I have PHP version 5.2 Answer : try using this: $_SERVER['SERVER_NAME'] EDIT: apache_request_headers() or parse $_SERVER['REQUEST_URI']
undefined
How to get current page URL in PHP get url in PHP function here Use the PHP $_SERVER Superglobal Variable You can use the $_SERVER built-in variable to get the current page URL in PHP. The $_SERVER is a superglobal variable, which means it is always available in all scopes. Also if you want full URL of the page you'll need to check the scheme name (or protocol), whether it is http or https as shown in the example below: <?php $uri = $_SERVER['REQUEST_URI']; echo $uri; // Outputs:
undefined
Get the client IP address using PHP How can I get the client IP address using PHP? I want to keep record of the user who logged into my website through his/her IP address. Best answer : The simplest way to get the visitor’s/client’s IP address is using the $_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_HOST'] variables. However, sometimes this does not return the correct IP address of the visitor, so we can use some other server variables to get the IP address. The below both functions are equivalent with the difference only
undefined
Remove .php extension (explicitly written) for friendly URL htaccess to remove the .php extension of my site's files. RewriteEngine on RewriteBase / RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.*)$ $1.php [L,QSA] Now, if I go to my site www.mysite.com/home works fine, it redirects to home.php but the URL is still friendly. But if I write this URL: www.mysite.com/home.php The home.php is served, and the URL is not friendly. How can I avoid this behavior? I want that if the user writes www.mysite.com/home.php,

Get time difference only from hours and minutes Problem: I have two times one is $InTime : 12:55:10 and the other is $OutTime : 12:56:10 So I think calculating the time difference should be: $TotalTimeInOffice = $OutTime - $InTime I want in hours so I think this should be the result 00:01, but I am getting wrong result. With this calculation I am get 0 in the result, but why? Here are some examples from database: InTime is: 12:55:10 OutTime is: 12:56:09 Result Is: 0 InTime is: 12:24:45 OutTime is: 00:00:00 Result Is: