Sunday, August 30, 2015

file writing and file appending || file handling in php

<?php
/*
 *file reading and file appending
 * */
$pointer = fopen('hello.txt', 'w');//mode is w means file open for writing purpose
fwrite($pointer, "Hello world\n"); //that will replace all existing sentence or word and write hello world in hello.txt file
fclose($pointer);

$pointer = fopen('hello.txt', 'a');//mode is a means file open for appending some line / word
fwrite($pointer, 'Hello world in another line');

No comments:

Post a Comment

css snippet for blogger code highlighting

code, .code {     display: block;     background: beige;     padding: 10px;     margin: 8px 15px; }