This code $route['basketball'] = "controller/product/?id=7" does not work.
function product()
{
echo $_GET['id'] // no output
}
How to describe the rules in the route?
This code $route['basketball'] = "controller/product/?id=7" does not work.
function product()
{
echo $_GET['id'] // no output
}
How to describe the rules in the route?
If possible use CodeIgniter's standard URL routes. In your case:
$route['basketball'] = "controller/product/7";
function product()
{
}
OR if $_GET['id'] needs to be dynamic
$route['basketball/:num'] = "controller/product";
function product($id)
{
}
Hope that helps.
Because you are in PHP , you can basically set $_GET and $_REQUEST parameters which are super global variables that can be accessed anywhere in the code. So you can do a callback and set them there.
For example:
$route['basketball'] = function(){
$_GET['id']=$_REQUEST['id'] = 7;
return "controller/product/";
};
Then in your code you can access $_GET['id'] or whatever.