PHP cannot be hosted in Corona – it needs to live on a web server that supports PHP. If you have a web server, you would create a file on it and then request it from Corona using network.request().
Example:
getUserAgent.php
[lua]<?php
echo $_SERVER[‘HTTP_USER_AGENT’];
?>[/lua]
That’s all you need to put on the web server. Then, in your Corona code, you would do this to get the user agent string into a variable:
[lua]local userAgent --variable that will store the user-agent string
local function networkListener( event )
if ( event.isError ) then
print( “Network error!” )
else
userAgent = event.response
print ( "RESPONSE: " … event.response )
end
end
network.request( “http://your website.com/getUserAgent.php”, “GET”, networkListener )[/lua]
Again, this is only possible if you have access to a web server that supports a scripting language such as PHP. Alternatively, there may already be a page publicly hosted somewhere on the internet that does this, but I have not looked.