Before the hyperlink jump, execute the function as the question & nbsp; purpose: click a hyperlink & nbsp; onclick () function to assign a value to the session & nbsp; and then output this value on the page after the jump: why didn't I execute the clicked function & nbsp; no matter whether it returns false or true & nbsp; no value is assigned to the session, the function is executed before the hyperlink jumps.
Example
Objective: to click a hyperlink onclick () function to assign values to the session and then output the value on the page after the jump
Q: Why are I unable to execute the Click link function? no matter whether it returns false or true, it cannot be assigned a value in the session. the page after the jump is blank.
Hyperlink page code
Session_start ();
Function f1 ()
{
$ _ SESSION ['test'] = "wewew ";
Echo "wocaoeo ";
Return false;
}
?>
Click run f1
Page code to jump
Session_start ();
Echo $ _ SESSION ['test'];
?>
PHP hyperlink functions:
------ Solution --------------------
Onclick is executed on the client, and php code on the server cannot be executed.
------ Solution --------------------
Onclick can only execute js code. if you want to trigger a php session value, you can trigger an ajax request in onclick to execute php session value initialization, jump to test again based on the ajax request value. php page