0

please help. im stuck in working with deleteing files. i cant figure out what is after puts f.

Fill in the blanks to open a file and output its contents if the file exists. Otherwise, output the corresponding error message. if File.file?("demo.txt") f=file.open("demo.txt") puts f. f.close else end

11th Nov 2016, 10:19 AM
Rhonda
Rhonda - avatar
1 Respuesta
+ 1
you can use different method to open a file and read its content if it exists. But for this I can give you; <?php $file = "demo.txt"; $handle = fopen($file, "r"); if(file_exists($file){ $cont = fread( $handle, filesize($file) ); echo $cont; }else{ echo "your error msg"; } fclose($handle); ?> you might surround it with try catch block and handle your exception.
11th Nov 2016, 3:25 PM
ARB
ARB - avatar