How to pass arguments to PHP function from anchor link -


can pass arguments php function when user clicks on anchor link i.e. tag like:

<a href="<?php myfunction($a, $b, $c); ?>">click here</a> 

and php function in same document like:

<?php    function myfunction($val1, $val2, $val3)    {      echo "<br>you passed: ".$val1.",".$val2.",".$val3;     } ?> 

help me please.

php server side code , executes there only. executes before sending output requesting client.

<a href="<?php myfunction($a, $b, $c); ?>">click here</a> 

that leave empty href attribute, , call myfunction() (in server side processing) while doing it. if want run php function on user event, need send request server, listen event occurred on page requested, , processing there.

for example, link can like

<a href="/your/page.php?func=myfunction">click here</a> 

then in /your/page.php, can check query string in url

if(isset($_get["func"]) && $_get["func"] === "myfunction") {     myfunction($a, $b, $c); } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -