Home > Backend Development > PHP Tutorial > How to generate machine code in php

How to generate machine code in php

WBOY
Release: 2016-07-06 13:54:11
Original
3485 people have browsed it

How to generate a machine code in php, a unique value for a client, without duplication, similar to a mac address, so that each machine can only have one registration, preventing registration swiping

Reply content:

How to generate a machine code in php, a unique value for a client, without duplication, similar to a mac address, so that each machine can only have one registration, preventing registration swiping

It is recommended that this unique identification number should not be used on the server anymore. In the app client interface I have made, whether it is docking IOS or Android, the client will generate a unique Token value and give it to our server. We only need to receive the identification. There is really no need for us to produce it. If you have to do unique generation on the server side, use the PHP built-in function uniqid() to produce it. This is accurate and subtle enough. You can add some parameters yourself. I hope it will be helpful to you

This depends on the specific situation. If the servers are all in a cluster, you can use the server IP, process id, and timestamp

<code>base_convert(ip2long($_SERVER['REMOTE_ADDR']),10,36).'-'.getmypid().'-'.base_convert(microtime(true)*1000 - strtotime('2016-06-07 18:00:00')*1000,10,36)
</code>
Copy after login

It is characterized by being messy and long. At the same time, if there are multiple clusters and the internal IP segments are consistent, it will not work. The advantage is that each server generates it independently.

In addition, the auto-increment of redis and the auto-increment of mysql are also possible. These solutions seem simple, but they are troublesome to maintain. For example, if redis hangs, how to restore the auto-increment field, etc.

Generated by the client, just randomly generate a 6-byte copycat mac address. Basically it will not be repeated and it will be stored in the keychain.

Related labels:
php
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template