I assume the answer is: “it is not possible because php is server language not client language”, but I would like someone more expert than me to state this and eventually list all possible workarounds…
Question: is it (at all) possible to have a php function executed (only) when the user “clicks” or performs some other kind of action (e.g. mouse-over) in an html page without using any javascript?
(P.S. As a workaround I considered to access an intermediate page containing the php code to be executed when the client action occurs and then redirect as needed but this is not straightforward as far as passing the results of the php code goes.)
This is not possible without making a new request.
You must use a link to send the user to a new page (or the same page — anything as long as a new request is made), or you must use something like AJAX.
There is actually one very hack-ish way I can think of. It’s not exactly pretty, but it should work.
You could use an iframe as the target for a link. Basically instead of a link opening in the same or a new window, it would open in a hidden iframe.
Untested, but in theory:
Edit: After some rough testing, it looks like chrome will not obey this. IE9 will to some extent though, it seems.