On Tue, May 7, 2013 at 8:16 AM, Curtis Maurand <curtis@xxxxxxxxxxx> wrote: > Hello, > I'm feeding a filename to a php script on the command line (command line > program). I run the following against it: > > $inputline = fread($inputfile, filesize($argv[1])); > > I'm getting an error complaining that the second parameter can't be '0' The thing to look for, is how did you get $inputfile out of the command line, and why you'd expect the file name to be in $argv[1] at that point? Marco's suggestion isn't really going to work as $inputfile will be a file handle, and filesize() needs the name of the file. Maybe want to give us a wider look at what your code is doing? Generically, you can wrap this up as: function binread_file($filename) { $handle = fopen($filename,'rb'); if (FALSE === $handle) die("Unable to open $filename"); $contents = fread($handle, filesize($filename)); if (FALSE === $contents) die("Unable to read $filename"); return $contents; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php