mirsad
mirsad

Reputation: 182

Save JS output with PHP

i want to save output/result of JavaScript code. For example:

<script>document.write(navigator.appVersion)</script>

For PHP i have no problem:

$ip = $_SERVER['REMOTE_ADDR']; 
$file = "log.txt"; 
$open = fopen($file, "a+"); 

Then write:

fwrite($open, "<b>IP Address:</b> " .$ip . "<br/>"); 

Now i'd like to write result of JavaScript with same method.

Of course this will not work:

fwrite($open, "<script>document.write(navigator.appVersion)</script>");

Any help?

Thanks

Upvotes: 1

Views: 349

Answers (1)

Tchoupi
Tchoupi

Reputation: 14691

If you need to get information about the user's browser, use a PHP function. You can't get the Javascript output from PHP unless you send it back using Ajax.

To get the browser information using PHP, use get_browser()

Upvotes: 2

Related Questions