write in a fil log the result of one echo



if I have this code
<?php
if (VAR1) {echo "<!-- funz1();print_r(xxxx);echo "-->"; }
?>

that make comments in html's page source;

how I can to achieve all in a file (and not send in html page) ?

and is also possible to make a file every day so not write always in same
file, but every day to make automatically a file where to write; ?
.