Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you start a filename with a $?

Tags:

php

I've never even considered this before, but one of my clients is trying to name a file starting with a $; $template.php.

Is this allowed?

I'd like to be able to give him a reason if it's no allowed?

Thanks!

like image 401
Rick Avatar asked Mar 20 '23 21:03

Rick


1 Answers

That depends entirely on what filesystem you're using. You can start a filename with $ on all of the major filesystems I know of — FAT, FAT32, NTFS, ext2, ext3, ext4, ... (Huh. My experience of file systems is actually quite limited. Interesting.)

Remember that if you're doing this from PHP, you need to be sure you're not using a string literal in double quotes, because within a string literal in double quotes, $ introduces a variable. If you're using a literal $, either use single quotes or escape it with a backslash.

like image 118
T.J. Crowder Avatar answered Mar 31 '23 23:03

T.J. Crowder