Did you try:
<?php
$t = "goiter";
if (preg_match("/\\$/", $t) == 1) {
print "Hi!";
}
?>
btw, dont use the [php] bbcode tags if you are going to post characters escaped with backslashes, the parser parses them out anyway.
EDIT:
conversely, you could use:
<?php
$t = "goiter";
if (preg_match('/\$/, $t) == 1) {
print "Hi!";
}
?>
The issue is more of a double quote vs single quote thing.
Basically, PHP considers "\$" to be an escaped $ sign.
This means that within a pattern, it is treated as a $ sign, not an escaped $ sign.
But the $ sign is the end marker, so the actual content of the pattern is blank.
Since the null set is a subset of all sets, there is a match, so "Hi!" is printed.
However, the $ sign does not need to be escaped within single quotes, as such, \$ is \$, so the output is as expected.