According to this "Cloaking refers to the practice of presenting different content or URLs to human users and search engines" The same link gives example as:
Serving a page of HTML text to search engines, while showing a page of images or Flash to users
Question: If I had correctly interpreted, there must be a mechanism for identification of the entity whether it is search engine or browser(user) at the web server.What do we call such mechanism? Or is it just a php or JavaScript code that redirects? How does a web-server actually know that entity'X' search engine and entity'Y' is web browser?
The user agent is a good way to identify the client.
This is the user agent string passed to the server on a request from a browser:
From Google:
From Bing:
To use them with PHP, you may do something like this:
If you want to be a little more precise, you might want to also check for a link, like so:
This question and answers show how to use Apache to deliver different content based on user agent: Rewrite rule for user agent with mod_rewrite