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
Post a Comment