Put it in the initial page. That is the first page user would open. such as index page or login page.
If it figured out that the client device is mobile save that information to session. As a matter of fact its not a big deal. you dont even need to remember whether it is a mobile device or not. But If the set of functions are different for mobile and pc then you can use the session variable to determine about which function to call.
more over when it would redirect to page allocated for mobile do not put any link to those mobile page that redirect to pc pages
I am new to php and i m using xampp server to run php .I am using notepad now .I would like to know is there any editor for php .Also I would like to know is it possible to integrate the editor or tool like netbeans with xamp server.Thanks in advance
There are plenty IDE's and editors out there. You have already said Netbeans. You can also take a look at (1) Notepad++, (2) Aptana, (3) Microsoft Expressions Web, (4) Adobe DreamWeaver, (5) Eclipse. This list is not exhaustive. With the exception of (3) and (4) in my list, the others are free to download and use.