Home > Backend Development > PHP Tutorial > 如何判断MVC里的C控制器的定义方法?

如何判断MVC里的C控制器的定义方法?

WBOY
Release: 2016-06-06 20:31:14
Original
1106 people have browsed it

我想自己写框架,如何判断控制器里定义函数呢?
比方说C控制器里的

<code>class PageController
{ 
function index() 
{ 
echo "单页";
} 
</code>
Copy after login
Copy after login

然后输入地址 index.phpc?c=page&a=index 可以打开
要是非法输入 index.phpc?c=page&a=index2 或者index.phpc?c=page&a=xxxx
会报错function 定义函数不存在Fatal error: Call to undefined method PageController::xxx()

我想实现,如何判断函数或方法不存在直接跳转404呢?

<code>function ???() 
{ 
echo "404";
} 
</code>
Copy after login
Copy after login

回复内容:

我想自己写框架,如何判断控制器里定义函数呢?
比方说C控制器里的

<code>class PageController
{ 
function index() 
{ 
echo "单页";
} 
</code>
Copy after login
Copy after login

然后输入地址 index.phpc?c=page&a=index 可以打开
要是非法输入 index.phpc?c=page&a=index2 或者index.phpc?c=page&a=xxxx
会报错function 定义函数不存在Fatal error: Call to undefined method PageController::xxx()

我想实现,如何判断函数或方法不存在直接跳转404呢?

<code>function ???() 
{ 
echo "404";
} 
</code>
Copy after login
Copy after login
Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template