If you go to Github or some other tech community, you’ll often see this pixelated avatar:
Pixelated avatar of v2EX community
This kind of avatar is generally to let the user who has not uploaded the avatar can present a variety of effects, to avoid the embarrassment of a single default avatar.
例 句 : There’s a term for this head: Identicon. So if you’re looking for that, you just search Identicon.
What I want is a PHP version. After comparing many projects, I found that only Yzalis /Identicon did a better job. The results are as follows:
However, this library use is a bit problematic for beginners.
1. The method of use described in the yzalis/Identicon document uses composer. Json, which many people don’t know well, including me.
2. The use keyword is used in the source code of yzalis/Identicon, which is not supported by PHP versions with earlier versions and requires PHP5.3. Ps: Strange is that I php5.4 will also report errors ~
Here’s a very traditional PHP way to use the library.
In fact, it is to solve the above two problems.
Json is a dependency management problem that you don’t need to deal with, including the following code:
Copy the code
Dependencies can be addressed using require_once.
There is also the problem of use. Remove all the keywords of use and namespace from the source code. Replace them with require_once where use is used, and remove namespace directly.
If you don't know how to do this, just download one of my modified versions, okayGithub.com/jianghejie/... 。
Index.php is an example of using this library in the modified project.
To see whether the effect of input url:http://www.xxxx.com/Identicon/index.php?string=test&size=48 directly