tags:

views:

335

answers:

3

To grab the inode of a file in PHP, you can use this:

$fs = stat($file);
echo $fs['ino'];

The problem with this is EVERYWHERE says it's slow and you should avoid it. So the question becomes what's the fast(er) way to do it?

+1  A: 

You could use fileinode() but you should run benchmarks if you think it is slow.

mercutio
A: 

I think you should benchmark and take a look at what you are doing to determine if stat() is the slowest part of your code. Stating 1 file on each request on a server that gets about 100 hits/day is not a problem. Stating every file could be a problem when you have to eek out a few more requests a second.

You can avoid stating the same file repeatedly by caching the results via memcached, apc or some other in-memory caching system.

Premature optimization is the root of all evil. - Donald Knuth

Ryan Doherty
A: 

Your operating system does dozens of stat calls per second already. Don't worry about it.

rix0rrr