Get random names using time and mt_rand function
This knowledge will be used in file uploading and other occasions. I haven’t learned object-oriented yet, so now I present it to you in functional form
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2016/9/19 0019 * Time: 19:47 */ function rdname(){ $t = getdate(); $year=$t['year']; $month = $t['mon']<10? "0".$t['mon']:$t['mon']; $day = $t['mday']>9?$t['mday']:"0".$t['mday']; $hour= $t['hours']>9?$t['hours']:"0".$t['hours']; $min = $t['minutes']>9?$t['minutes']:"0".$t['minutes']; $sec = $t['seconds']>9?$t['seconds']:"0".$t['seconds']; $randnum=mt_rand(1000,9999);//获取随机的4个数字 $randname=$year.$month.$day.$hour.$min.$sec.$randnum;//把年月日时分和随机数拼接起来 return $randname;//返回新的名字 } $newname=rdname();//把返回的名字赋值给$newname echo $newname; ?>
Copy after login
Effect display:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
What's New in Windows 11 KB5054979 & How to Fix Update Issues
3 weeks ago
By DDD
How to fix KB5055523 fails to install in Windows 11?
2 weeks ago
By DDD
InZoi: How To Apply To School And University
4 weeks ago
By DDD
How to fix KB5055518 fails to install in Windows 10?
2 weeks ago
By DDD
Roblox: Dead Rails – How To Summon And Defeat Nikola Tesla
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
