The following code checks if we can use extended attributes.
<?php $file = 'some_file'; if (xattr_supported($file)) { /* ... make use of some xattr_* functions ... */}?>