ThinkPHP? ???? ????? ??? ? ???? ?? ??? ?????. ??? ??? ????? ??? ???? ??? ??? ???? ??? ??? ?????. ? ?? ???? ThinkPHP? ? ? ??? ? ??? ? ???? ThinkPHP? ???? ???? ??? ??? ???????.
1. ???? ??
???? URL? ?? ???? ???? URL? ?? ???? ? ???? ???? ?? ?????. ??? ??? ???? ???? ? ???? ? ???????? ????? URL? ?? URL? ???? ??? ?? ??? ?????. ThinkPHP? ???? ?? ???? ?? ???? ? ?? ???? ?????.
2. ?? ???
?? ???? ThinkPHP? Route ???? ?? ??? ??? ???? ?? ?????. ? ??? ??? ???? ????? ????, ??? ??? ??? ??? ??? ??? ????.
1. ?? ??? ??
?? ??? ??? ?? ?????. config/route.php ??? ??? ??? ???? ???.
use?think\facade\Route; //?定義路由規(guī)則 Route::rule('hello/:name',?'index/hello');
2. ?? ???? ??????. ??? ??? ?? ?????. ?? ???? ?? URL? ???? ???? ? ????. ?? ?? ? ??? ??? ??? ??? ?? ??? ? ????:
http://localhost/index/hello/name/ThinkPHP
3. Annotation ???
Annotation ???? Annotation? ?? ?????? ??? ??? ???? ?? ?????. ? ??? ??? ??? ??? ????? ???? ????? ?? ??? ? ???? ???? ??? ???? ????? ??? ???? ??? ??? ?? ????.
1. ?? ??? ??
?? ???? ??? ?? ???? ??? ?? @route
??? ???? ??? ??? ???? ???. ?:
<?php namespace?app\index\controller; /** ?*?@route('hello/:name',?method='get') ?*/ class?Index { ????public?function?hello($name) ????{ ????????return?'Hello,'?.?$name?.?'!'; ????} }
? ????? GET ?? ???? ???? ??? ??? hello/:name
???. @route
注解來(lái)定義路由規(guī)則。例如:
http://localhost/hello/name/ThinkPHP
在上述代碼中,我們使用了 GET 請(qǐng)求方式,而路由規(guī)則為 hello/:name
。
2、注解路由的訪問(wèn)
訪問(wèn)注解路由同樣需要在地址欄中輸入對(duì)應(yīng)的 URL。例如,上述代碼中的路由規(guī)則可以如下訪問(wèn):
use?think\facade\Route; //?修改路由規(guī)則 Route::rule('hello/:age',?'index/hello');
四、路由的修改
當(dāng)我們?cè)陂_(kāi)發(fā)項(xiàng)目的過(guò)程中,需要修改已有的路由規(guī)則時(shí),可以使用以下幾種方式進(jìn)行修改:
1、基礎(chǔ)路由的修改
基礎(chǔ)路由的修改非常簡(jiǎn)單,只需在 config/route.php 文件中對(duì)應(yīng)的路由規(guī)則處修改即可。例如,修改 hello/:name 的路由規(guī)則為 hello/:age,代碼如下:
<?php namespace?app\index\controller; /** ?*?@route('newhello/:name',?method='get') ?*/ class?Index { ????public?function?hello($name) ????{ ????????return?'Hello,'?.?$name?.?'!'; ????} }
2、注解路由的修改
注解路由的修改也非常簡(jiǎn)單,只需在對(duì)應(yīng)的控制器中修改即可。例如,修改 Index 控制器的路由規(guī)則為 newhello/:name
rrreee
IV. ??? ?? ???? ?? ?? ?? ??? ??? ???? ?? ?? ?? ??? ???? ??? ? ????. it: ?? ??1. ?? ??? ?????? ?? ??? ??? ?? ?????. config/route.php ???? ?? ??? ??? ???? ???. ?? ?? hello/:name? ??? ??? hello/:age? ???? ??? ??? ????. ??rrreee??2. ?? ??? ?????? ?? ??? ??? ?? ?????. ?? ????. ?? ?? Index ????? ??? ???newhello/:name
?? ???? ??? ??? ????. ??rrreee?????? ??? ? ?? ???? ??? ? ????. ????5. ?????????? ? ??????? ??? ? ???? ???? ?? ?????. ThinkPHP? ???? ?? ???? ?? ???? ? ?? ???? ?????. ??? ?? ??? ??? ??? ??? ? ????. ??? ??? ??? ???? ??????? ?? ?? ? ??? ? ?? ??? ??????? ???? ??? ??? ???? ?? ????. ??? ??? ThinkPHP?? ???? ???? ??? ?? ??? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)