關於生成隨機數 str_pad

附上官方文檔 

https://www.w3school.com.cn/php/func_string_str_pad.asp

str_pad() expects parameter 1 to be string, integer given

str_pad(string,length,pad_string,pad_type)

結果一直報錯 在生成隨機數階段  大部分博客直接拿的int類型的數字 !!!!!

最後修改代碼

$rand = mt_rand(1, 99999);
$strand = str_pad((string)$rand,7,"0",STR_PAD_LEFT);

完事

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章