php - How to get some portion in the url? -


i working in php. want portion of url using php,

for example, url "http://localhost:82/index.php?route=product/product&path=117&product_id=2153". want route=product/product only.

since variable might not exist, (and should) ensure code not trigger notices with:

<?php if (isset($_get['route'])) {     $route = $_get['route']; }else{     // fallback behaviour goes here } 

alternatively, if want skip manual index checks , maybe add further validations can use filter extension:

<?php  echo filter_input(input_get, 'route'); 

you can read using $_request below:

<?php     echo $_request['route']; ?> 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -