How to calculate size of folder?

Ok, how would I make a php get the size of a folder…?

What im trying to do is:

Get size of folder with contents
see if the size of folder is equal to limit