Home  >  Article  >  Backend Development  >  How to access a method in a php file

How to access a method in a php file

Guanhui
GuanhuiOriginal
2020-05-04 15:48:313986browse

How to access a method in a php file

How to access a method in a php file

First, you can write the method name into the URL;

How to access a method in a php file

Then get the method name through "$_GET" in the php file;

$action = $_GET['action'];

Finally, call the method corresponding to the method name through the "call_user_func()" function, The return value is the value returned in the method.

$action = $_GET['action'];

function test()
{
    echo "测试";
}

call_user_func($action);

Output result: ce

The above is the detailed content of How to access a method in a php file. For more information, please follow other related articles on the PHP Chinese website!

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