php get url parameters

If you are looking for get url parameters in php then no need to write any logic or condition for getting it.Php has in built function called as “parse_url” this function return as array with parameter like host,path,query,fragment and more options.For more explanation please refer bellow given example.

  $url = 'http://www.my-php-scripts.net/index.php?arg=value&args2=dfsdfsf#anchor'; 
  print_r($url); 

This will return following

  Array ( 
          [scheme] => http 
          [host] => www.my-php-scripts.net 
          [path] => /index.php 
          [query] => arg=value&args2=dfsdfsf 
          [fragment] => anchor 
) 

If you mean url parameter as logically form then you can use $_GET[‘param_name’] to get it.

Leave a Reply

Your email address will not be published. Required fields are marked *