× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Get localhost project name from url

Jérôme Gamez
May 06, 2015
<p>You can retrieve the parts of an URL with the <code>parse_url()</code> function:</p> <pre><code>$url = 'http://localhost/project1/'; $parts = parse_url($url); print_r($parts); </code></pre> <p>Output:</p> <pre><code>Array ( [scheme] =&gt; http [host] =&gt; localhost [path] =&gt; /project1/ ) </code></pre> <p>Or, if you want to get the path directly:</p> <pre><code>$path = parse_url($url, PHP_URL_PATH); // =&gt; /project1/ </code></pre> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/30021034/Get%20localhost%20project%20name%20from%20url/30021066">Stack Overflow</a>.</p>
comments powered by Disqus