🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ## 安装 `composer req fzaninotto/faker ` ## 示例 ### 简单示例 ``` $faker = Faker\Factory::create('zh_CN'); echo $faker->name.PHP_EOL; // 阎文彬 echo $faker->city.PHP_EOL; // 南京 echo $faker->email.PHP_EOL; // tenetur.libero@yahoo.com ``` ### 伪造用户名 ``` $faker = Faker\Factory::create('zh_CN'); echo $faker->name . PHP_EOL; // 苗娟 echo $faker->address.PHP_EOL ; //哈尔滨高明区 ``` ### 伪造颜色 ``` $faker = Faker\Factory::create('zh_CN'); echo $faker->hexcolor . "\n"; // #dcf422 echo $faker->rgbcolor . "\n"; // 208,156,194 dump($faker->rgbColorAsArray); //array:3 [ // 0 => 208 // 1 => 109 // 2 => 68 //] echo $faker->rgbCssColor . "\n"; // rgb(1,122,206) echo $faker->safeColorName . "\n"; // 鲜绿色 echo $faker->colorName . "\n"; // 银色 ``` ### 伪造手机号 ``` $faker = Faker\Factory::create('zh_CN'); echo $faker->phoneNumber.PHP_EOL; // 17034092720 ``` ### 互联网相关数据 ``` $faker = Faker\Factory::create('zh_CN'); echo $faker->email . "\n"; // doloribus_non@hotmail.com echo $faker->userName . "\n"; // nnon echo $faker->password . "\n"; // ME!!UZJ^0Bvp echo $faker->url . "\n"; // http://www.zhang.com/quod-rerum-rerum-ex-atque-qui-delectus echo $faker->slug . "\n"; // eius-impedit-similique-harum-et-aut echo $faker->ipv4 . "\n"; // 30.178.126.218 echo $faker->localIpv4 . "\n"; // 10.193.39.235 echo $faker->ipv6 . "\n"; // 2f1:25b6:d118:9b61:fa01:db07:980a:855e echo $faker->macAddress . "\n"; // 62:0D:86:86:2C:76 ```