Posts

Showing posts with the label write file

PHP Write Echo content to file

You can get the echo content to variable as fallows ob_start (); echo '<html>' ; echo '<div>' ; echo 'TEST PRINT' ; echo '</div>' ; echo '</html>' ; $content = ob_get_clean (); Write the echo content to file can achieve as fallows $fp = fopen ( $_SERVER [ 'DOCUMENT_ROOT' ] . "/test . html" , "wb" ); fwrite ( $fp , $content ); fclose ( $fp );