Posted By

anagaiyahoocom on 03/11/11


Tagged

joomla


Versions (?)

Extracting Path and Query String from Any URL String


 / Published in: PHP
 

You can use JUri object to extract the path or query string from a any url

  1. //current page
  2. $uri = JUri::getInstance();
  3.  
  4. //another link
  5. $uri = JUri::getInstance('/somedomain.com/subdir/page.html?param=val');
  6.  
  7. //Will extract ?param=val
  8. $qry = $uri->toString(array('query'));
  9.  
  10. //Will extract /somedomain.com/subdir/page.html
  11. $path = $uri->toString(array('path'));

Report this snippet  

You need to login to post a comment.