What are the potential pitfalls of using special characters like ":" in file names generated by PHP scripts?

Using special characters like ":" in file names generated by PHP scripts can cause issues when trying to access or manipulate these files on different operating systems. To avoid potential pitfalls, it's best to sanitize file names by removing or replacing special characters with more standard ones before saving or using them.

$filename = "file:with:special:characters.txt";
$cleaned_filename = str_replace(":", "-", $filename);
echo $cleaned_filename;