preg_match if first char is slash

Viewed 1595

I try to find out if the first char of a string is a slash.

I have this string /var/www/html

$mystring = "/var/www/html";
$test = preg_match("/^/[.]/", $mystring);

if ($test == 1)
{
    echo "ret = 1";
}
else 
{
    echo "ret = 0";
}

But I always get ret = 0.

5 Answers
Related