I'm not sure but it looks like the first backslash turns the dollar sign into a variable then the second backslash turns it into a literal.
The ereg page in the PHP Manual does not say much about escaping dollar signs:
http://us2.php.net/manual/en/function.ereg.php
About half way down the page a user's comment (by Jason Smart) says this:
09-Sep-2005 11:01
Tries to escape with \ in a bracket expression
You cannot with ereg functions (preg you can) so
ereg("^([-a-zA-Z0-9_\.\!@#\$&\*\+\=\|])*$" , $var)
should be
<?php ereg("^([-a-zA-Z0-9_.!@#$&*+=|])*$", $var); ?>
I tried the example from Jason Smart's posting and it seems to work:
<?php $var = "$";
if (ereg("^([-a-zA-Z0-9_.!@#$&*+=|])*$", $var)){
echo "it seems to work";
}?>
The manual does not say anything about backslashing the dollar sign. Or if it does I can't find it. And an unorthodox example like above seems to work ok.
Neither way looks like it ought to work but both work.
Darnest thing I ever saw.
My only question is if somebody tries to call the script on a Mac (my desktop is a Windows Me version) or a newer version of Windows will it give them an error message?