<?php
/**
* 生成随机手机号码接口 PHP接口源代码
*
* 接口说明:生成随机11位手机号码,例如用于生成测试数据
*
* 最后修改:2024-10-12 16:59:02
*
* @author dogstar www.yesapi.cn
*
* 来源:https://open.yesapi.cn/apicode/8873.html
*/
function ($params, $di) {
$operator = $params['operator'];
$paragraph = [
['134', '135', '136', '137', '138', '139', '147', '150', '151', '152', '157', '158', '159', '172', '178', '182', '183', '184', '187', '188', '198'],
['130', '131', '132', '145', '155', '156', '166', '171', '175', '176', '185', '186', '166'],
['133', '149', '153', '173', '177', '180', '181', '189', '199']
];
// 除号码外的8位随机数
$num = rand(pow(10, (8 - 1)), pow(10, 8) - 1);
// 运营商类型
$type = $operator !== NULL ? $operator : mt_rand(0, 2);
$phone = $paragraph[$type][array_rand($paragraph[$type])] . $num;
return ['phone' => $phone];
}
在线运行
生成随机手机号码接口 - 免费接口源码库
持续更新中…… 免费使用,一键生成你的API
+ 复制到我的接口(请先登录,支持在线开发API)
预览接口发布效果
查看开发教程