PHP: Get path after domain from current URL -


I am beginning to complete PHP, so please keep this in mind.

Let's just get the path to the current URL, which is the variable. For example, if the current URL is http://example.com/blog/2014/blogpost.html then I want to get to / blog / 2014 or much more are equal.

I have PHP code so far:

  $ full_url = $ _SERVER ['HTTP_HOST']. $ _ Server ['PHP_SELF']; $ Path_info = parse_url ($ full_warns, PHP_URL_PATH); Echo $ path_info;  

However, this does not work, and I can not see the appropriate solution to Google.

Do anyone have any signs?

Thanks in advance!

You can use strrpos to get the last code < Drag the part of the URI before Code> / and before:

  $ req_uri = $ _SERVER ['REQUEST_URI']; $ Path = substr ($ req_uri, 0, stropo ($ req_uri, '/'));  

This will give you exactly what you need ( / blog / 2014 )


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -