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.)