Jump to content

Unix Commands in PHP


seventheyejosh

Recommended Posts

That question makes as much sense as "is there any practical use for a while loop?" It just depends on your imagination.

 

By the way, it's not "Unix commands", but any command on the host operating system.

 

As an example, the filesize() function is broken for files that are larger than 2 GiB (because all integers in PHP are signed 32-bit integers*). You can use some hacks to get accurate results for > 2 GiB sizes using commands on the underlying operating system. That's just one example. As I said, it's really up to your own imagination.

 

 

* In an n-bit integer you can address 2n different integers. If the unit is bytes and you are using 32 bits you can address 232 B = 4,294,967,296 B = 4 GiB. However, because we in this case have a signed integer, half of the addressable numbers are negative, so that leave us with 2 GiB.

Link to comment
Share on other sites

but, is there anything practical anyone uses it for? At least on a production basis?

 

I can't remember the last time I used a *nix specific command in a PHP script, but I use the exec() function for interacting with ImageMagick fairly regularly.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.