PHP implementation of the colorful tag effect code sharing, PHP implementation tag Code _php tutorial

Source: Internet
Author: User

PHP implementation of the colorful tag effect code sharing, PHP implementation tag code


At present, everyone's blog on the left side usually add a beautiful colorful logo, but also want to give their small station to add this little function.

Unfortunately it is no longer the use of WordPress is so convenient, using WordPress friends directly using the ready-made plug-in, the mouse point can be added to this colorful function. A small station program is self-written, to add such a function or to do it yourself, learn it!

First of all, I analyzed the current color of the main manifestations of the label, there are two points: different colors, different sizes. This is a feature of the colorful label, so I think of the random function rand in PHP. Direct to size, color with Rand random value can be.

The size of the random value is easy to handle, directly generated after the connection unit can
Copy the Code code as follows:
<?php
Random Size instances
$m = rand (20,30);
Echo ' random size ';
?>
Generating color values is a little trickier because the color value is a hexadecimal character representation, and the random function rand cannot directly generate 0 to F so that it can be used to save the hexadecimal character directly with the array, and then randomly generate the mouse subscript so that the random color is also possible.
Copy the Code code as follows:
<?php
Random color function
Directly returns a randomly generated color value
function GetColor () {
Characters the hexadecimal character in an array with an array first
$arr = Array (' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' A ', ' B ', ' C ', ' D ', ' E ', ' F ');

Because the color value is 6 bits long, loop 6 times
for ($i =0; $i <6; $i + +) {
Randomly generate 0 to 15 numbers, and then take the value as an array subscript
$color. = $arr [Rand (0,15)];
}

When you return, add the # number.
Return ' # '. $color;
}
?>
Random size, random color after the rest of the problem is not the problem. Simply take out all the labels and go to the weight, then iterate over the array to generate the HTML text.

At the end of the recommendation, after all, PHP is the server side, each time Rand will make the server pear is not small (those special cow machine can be ignored, after all, there are still many VPS). We can generate the tags in the blog when changes occur, such as delete, modify, add the article generated new tags when we go to generate colorful tags HTML text. Finally, these generated multi-color signed HTML does not need to be stored in the database, directly stored in a file, and then include.

At present, this is how my station is realized. Free, I will introduce JavaScript to implement colorful tags, the same principle is the same, just JavaScript is the client behavior, do not worry about the server side of the pear, and JavaScript interactivity is better, you can make animated cloud tags.


Who has PHP code that implements the slideshow effect in a webpage

That's the effect of js+html tag +css or Js+flash,
Code Baidu a bit, not good or not suitable for, self-improvement again!
Others give you in fact is not perfect for you, because not specifically for you born ...
Then of course you have to adapt to your own needs to adapt to the AH ...

How do I add php code to a page's div tag with javascript?

This is impossible. PHP is executed before the page is generated, and JavaScript is taken after the build. The page you open with your browser is actually not visible to implement what you said there are two ways:
One is to create a separate page to include 2.php, and then go directly to the new page where the outmsg () is executed.
The second is to add a parameter in the current page, in PHP with $_request[' parameter name '] to obtain, and then use if the judgment, if there are parameters, then include 2.php, otherwise include 1.php. When the current page executes outmsg (), it is submitted to the current page with a form, adding this parameter.

http://www.bkjia.com/PHPjc/867249.html www.bkjia.com true http://www.bkjia.com/PHPjc/867249.html techarticle PHP Implementation of the multi-color tag effect code sharing, PHP implementation tag code at present, everyone's blog on the left side usually add a beautiful colorful mark, also want to give their small station to add this little work ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.