Home >Backend Development >PHP Tutorial > 新手求教,该如何解决

新手求教,该如何解决

WBOY
WBOYOriginal
2016-06-13 13:35:23866browse

新手求教
假如请求url后面没有指名文件,PHP怎么处理,如后面是user/123,请求url的话,PHP怎样才能处理?如果是user/xxx/ 呢,新手请教!!!

------解决方案--------------------
这首先要依靠服务器的url重写,内部重定向到php。
你说的这种情况通常就是适用于MVC模式下的重写,将非文件的请求全部都重写到入口php文件,再解析请求的路径(例如 /user/123),调用对应的控制器

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn