Four PHP Command-Line Functions
Typically I never read the technical articles on ibm.com. They are long and complicated. However, I was very interested on an IBM article today when I googled “php linux command”. It is titled Use Command-line tools in PHP. I experienced shell_exec(), exec(), passthru(), and system() functions by following the article. It explains the different usages between these four functions. To summarize them:
- shell_exec() is similar to backtick(`) operator which I used most often.
- exec() assigns its output result to an array variable. Apart from that, it is the same as shell_exec().
- passthru() directly outputs the result without using the echo statement, but you can assign the last argument to it to output the error code for debugging purpose.
- system() acts like a hybrid between passthru() and exec().
One function I was having trouble is the system() function. The output of the function is similar to the passthru() function. However, I later aware that if a variable assigned to the system() function, the function outputs an array so that I can process them line by line.
Most of the Linux Code Comes From Companies
Most of GNU/Linux users are contributing to the Linux community either through Corporate Contribution or through Community Contribution. Recently, I found an interesting post at theregister.co.uk states that most of the Linux code(75%) comes from Corporation Contribution (which is paid to write the code), another 18% comes from community contribution (which is volunteered), and another 7% of the code is unclassified (which might also be volunteered).
The following are top companies that contributed to the 75% of Linux code:
Google and Apple, which both use Linux-based system, are absent from the GNU/Linux Contribution list. Perhaps those two companies have very little contribution to the Linux code? I know that Google has several Open Source projects and it’s building its own Linux distro, Chrome OS. Personally I don’t like Apple because its expensive hardware and almost all of the digital contents that come from Apple are DRM-restricted.
NOTE: This post is the correction of the earlier post. Some of the comments below might not reflect content of this post.