Why does the TP5 route fail to parse after adding dynamic parameters?

dynamically defines the route of a get request, which is OK without parameters, but not with dynamic parameters id

use think\Route;
Route::get("banner","api/v1.Banner/banner");

? >

the top is OK, but the bottom is not.

use think\Route;
Route::get("banner/:id","api/v1.Banner/banner");

? >

error message is:

clipboard.png

excuse me, what is this situation?

Php
Apr.18,2022

you can think of: id in banner/:id as a placeholder. All you have to do is replace it with the actual parameters.
eg:

  • banner/1

then define a parameter of $id in the parameters of the controller method to get it. Instead of getting it through $request.


above your URL is localhost/banner/?id=1
request directly with localhost/banner/1. When the controller receives parameters, it still uses id to receive

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b365b1-2b784.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b365b1-2b784.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?