That script is just outputting a small JavaScript snippet - You don't need to actually let it execute in the browser if you want to capture its result in PHP:
// Assuming you have [allow_url_fopen][1] enabled
$js = file_get_contents( 'http://www.gta4.it/stat/view_stats.js.php?mode=0');
$value = trim( str_replace( array( "document.write('", "');"), '', $js));
echo $value; // Outputs 9, the current value of the JS
Demo
Of course, if you're looking for a more robust solution that would still work if the JS snippet changes (introduces whitespace, changes quotation types, etc), you can use a regex to extract the number from the snippet. Something like this should work:
$js = file_get_contents( 'http://www.gta4.it/stat/view_stats.js.php?mode=0');
$value = preg_replace('/^\s*document\.write\(\s*[\'"](\d*)[\'"]\s*\)\s*;\s*$/im', '$1', $js);
echo $value; // Outputs 11, the now current value of the JS
Demo
If, for some reason, you want / need to let it execute in a browser before capturing the value, you can do something like this, although I'm sure it's not standards-compliant and seems pretty hackish.
- Wrap the
<script>
tag in a container, perhaps a <span>
or <div>
- Use JS to get the contents of the container.
- Use AJAX to send the result to a server.
Sample (untested):
<div id="stats_container">
<script type="text/javascript" src="http://www.gta4.it/stat/view_stats.js.php?mode=0"> </script>
</div>
<script type="text/javascript">
var value = document.getElementById( 'stats_container').innerHTML;
alert( value); // Here you would use AJAX to send the value to a server
</script>