<?php$fh = fopen( "archivo.txt", "w" );fwrite( $fh, "<?php \$variable = \"valor_de_la_variable\"; ?>" );fclose( $fh );?>