質問

Let's say for example in results q='sports', how would I be able to make it www.example.com/results?q=sports or whatever? And when I type manually in the url www.example.com/results?q=books it would search for books.

The response is in json btw.

役に立ちましたか?

解決

You will need to process the parameter from within whatever controller '/results' is routed to, eg:

if isset($_GET['q']) {
    $searchCategory = $_GET['q'];
}

Another option would be to have q as a function parameter on a controller method:

class MyController extends BaseController {
    public function __construct() {}

    public function getSearch($searchCategory) {
        // Do Stuff
    }
}

And this would be accessible via:

http://www.example.com/search/books
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top