0

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?

Chris Bartow
  • 14,873
  • 11
  • 43
  • 46

2 Answers2

1

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

Christian Gollhardt
  • 16,510
  • 17
  • 74
  • 111
mercutio
  • 22,151
  • 10
  • 36
  • 37
0

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
  • 38,580
  • 4
  • 56
  • 63