Currently, everyone usually adds a beautiful colorful mark on the left side of their blog, and I would like to add this small feature to my own website.
Unfortunately, it is no longer as convenient as when using WordPress. Friends who use WordPress can directly use ready-made plug-ins and add this dazzling function with just a click of the mouse. The small station program is written by myself. If you want to add such a function, you still have to do it yourself, so just think of it as learning!
First of all, I analyzed the main manifestations of colorful labels at present. There are two main points: various colors and different sizes. This is the characteristic of colorful tags, so I thought of the random function rand in PHP. Just give the size directly and use rand to randomly select the color.
Random values of sizes are easy to get, just generate them directly and connect the units
Finally, some suggestions. After all, PHP is a server-side, and running rand every time will make the server lose weight (those particularly powerful machines can be ignored, after all, there are still many people using VPS). We can regenerate the tags of the blog when they change, such as deleting, modifying, or adding new tags to the blog, and then generate the HTML text of the colorful tags. In the end, the generated colorful HTML does not need to be stored in the database. It can be saved directly in a file and then included.
Currently, this is how my website is implemented. When I have time, I will introduce JavaScript to implement colorful tags. The principle is almost the same, except that JavaScript is a client-side behavior, so you don’t have to worry about server-side problems. Moreover, JavaScript is relatively interactive and can create cloud tags with animated effects.
That is the effect of js+html tag+css or js+flash.
Baidu the code. If it is not easy to use or not suitable, please improve it yourself!
What others give you is actually not perfect for you, because it is not specially made for you. . . . .
Of course you have to change it to suit you according to your own needs. . . . .
This is impossible. PHP is executed before the page is generated, while javascript is executed after it is generated. You can't actually see the include.... PHP code in the page you open with your browser. What you see is the result after PHP execution.
There are two ways to achieve what you said:
One is to create a separate page to include 2.php, and then go directly to this new page where outmsg() is executed.
The second is to add a parameter to the current page, use $_REQUEST['parameter name'] to obtain it in PHP, and then use if to judge. If there is a parameter, include 2.php, otherwise include 1.php. When executing outmsg() on the current page, submit a form to the current page and add this parameter.