Not sure what you mean by "print the output". PHP can certainly open and process files. But perhaps you mean something else?
PHP IS a general purpose scripting language, much like perl. You can run it from the command line without undo difficulty. However, PHP's real strength is when it is used in conjunction with a web server and a database. Most of the thousands of functions in PHP are designed to make web/database development easier.
The developers of PHP have optimised it for web development, so that is where you are most likely to encounter it. It also means that if you are not doing web development there is likely a better tool available. Pick the right tool for the job.