I've to append a fixed int to a variable int. $a=variable number.
$b has to be $a+002 (for example). So, for example,
$a = 1; $b=1002
$a = 2; $b=2002
$a = 58; $b=58002
I could do $b=$a.'002'
; but this will be a string, right?
I've to put $b into a mySql database in a int(11) column.
Which is the most correct and safe way to do this?
Yes, you could just concatenate the string '002' onto $a.
$b = $a . '002'
The result will be a string, but it doesn't really matter. MySQL will parse it as an integer when you run your query.
If you really wanted an integer result you could just cast it as such:
$b = (int) ($a . '002');
Even if you cast it to an integer, your query is still going to be a string. On MySQL's end the query is going to be the same either way.