PHP has a type conversion philosofy, that will auto convert the type of the data on runtime depending on the context. This may have it's advantages and disadvantages, and there are people against it and people who think it's ok (like in almost everything in life).
For more info about its behaviour please have a look on the php documentation: http://www.php.net/manual/en/language.types.type-juggling.php
It will try to see the string as an integer to ease your life if you use the arithmetic operator "+"(detecting the first character "5"), but leading to strange behaviours if not done properly.
That doesn't mean it doesn't have a type, $b is actually a string, only that it tries to convert it on runtime, but $b will still remain as a string.
To check this and/or prevent the strange behaviours you could use the php native functions to check the types:
$a = 20;
$b = "5doller";
if(is_integer($b)){
$a+=$b;
} elseif (is_string($b)) {
$a.=$b;
}
echo $a;
Or you can use gettype() which will return the variable type, and do a switch case or whatever you like to it. But in my opinion it would be over-coding, just use your common sense and be careful and normally it will be ok.