This is my PHP script:
<?php
function myFunc($param1)
{
echo $param1;
}
if(isset($_GET['action'])){
if(function_exists($_GET['action'])) {
$_GET['action']();
}
}
?>
Now I want call this function from other php and pass parameter:
How to pass parameter to myFunc through url?
It is most certainly wrong and insecure (imagine what would happen if you tried calling it with action=unlink¶m=somefile.php
), but you could do something like:
With URL: http://localhost/data.php?action=myFunc¶m=123
<?php
function myFunc($param1)
{
echo $param1;
}
if(isset($_GET['action'])){
if(function_exists($_GET['action'])) {
$_GET['action']($_GET['param']);
}
}