Q:

How to check how the web resource is requested?

Using PHP, is there a way to check for certain how a web server resource is requested while minimising room for forging and hacking? Or in simpler terms, how to check whether it is a hyperlink click, direct URL, submission of HTML Form, programmatic access etc.?
What about if tools other than PHP is used?

A:

You can't make that bullet proof that way, but a good start is $_SERVER.
For example with $_SERVER['REQUEST_METHOD'] you can determine if the request was get/post/put/...
Regarding link click or direct access: $_SERVER['HTTP_REFERER'] might help.
At last $_SERVER['REQUEST_URI'] might hold some useable info, to determine if the script was run over an webserver (like apache) or the console.
Please see the documentation for more info on that.
And as I mentioned before: You can't be sure of anything here, but if you just want some info, and not use it for security reasons, you are fine.
If you want security you need to look into the possibilities with .htaccess.

