8
1
I have been participating in a number of PHP code golf challenges recently and some of the techniques that are used to read data from a file such as fopen()
and fread()
or file_get_contents()
really give my code a beating on the char count. Especially the methods provided for reading in command line input.
My question is, what is the fastest way (least keystrokes) to read and write to the contents of a file, and what is the fastest way (least keystrokes) to read a line from the prompt?
(Note: As this is code golf, I can't use any external libraries.)
Great! Do you have any advice on writing to a file? – Dan Prince – 2012-05-03T13:28:24.243
@DanPrince I've added a bit on writing. Can't see anything shorter on that at the moment though. – Gareth – 2012-05-03T13:35:32.423