title: How to know if a file name is valid on the current platform?
body: <p>All platforms (and probably filesystems) have different rules regarding which characters are allowed as a file or directory name. Furthermore, some systems have a blacklist of filenames: for example on Windows, <code>com1</code> is an invalid file name.</p>
  
  <p><strong>Is there a way to know programmatically the rules to compute a valid file name in PHP?</strong></p>
  
  <p>As an alternative, is there a trustable list of <em>safe</em> characters that are guaranteed to be valid on any system, apart from <code>[0-9a-zA-Z]</code>?</p>
  
  <p>Please note that a solution based on <em>try to save, if it fails, the filename is invalid</em> is not acceptable for my use case.</p>