Gabriel A. Zorrilla Gabriel A. Zorrilla - 7 months ago 12
PHP Question

Call PHP function from url?

If I want to execute a php script, i just point the browser to www.something.com/myscript.php

But if i want to execute a specific function inside myscript.php, is there a way? something like www.something.com/myscript.php.specificFunction

Thanks!

Answer

One quick way is to do things like

something.com/myscript.php?f=your_function_name

then in myscript.php

if(function_exists($_GET['f'])) {
   $_GET['f']();
}

But please, for the love of all kittens, don't abuse this.

Comments