Codice PHP:
echo str_pad($numero,6,'0',STR_PAD_LEFT);