PHP随机生成广告图片:

<?php /* 
+------------------------------------------------------------------+ 
| MikeCherim.com | 
| PHP: Ad Generator | 
| PHP Hypertext Preprocessor | 
| Copyright Dec 2006 | 
| Use with attribution by visible link please! | 
| Attribute to: <a href="http://green-beast.com/">Mike Cherim</a> | 
+------------------------------------------------------------------+ 
*/ ?>  <?php 
/* 
* GENERAL INFORMATION: 
* Implementation is simple and straight forward. I offer the script 
* in two sections. The array of arrays, and the output. Both can be 
* combined and placed on the page right where they're needed, or put 
* into two sections on the page, or the arrays can be placed in a 
* separate file and included. It's up to you and will probably be 
* decided by the number of ad arrays you will include. 
*/ 
?>  <?php 
/* 
* PART 1 - THE ARRAY OF ARRAYS 
* I have expanded this to make the script easier to negotiate 
* If you're using constant values, you can remove those parts. 
* If wanted, you could also add captions to the arrays below. 
*/ www.jbxue.com $ad_rand = array( 
1 => array( 
'url' => 'somesite1.com', // Url of advertiser or stats recording redirect 
'img' => 'image1.jpg', // Add file name, type, even path if needed 
'ttl' => 'Tool Tip 1', // Recommended title text (tool tip) 
'alt' => 'Alt Text 1' // Required alternate text 
), 
2 => array( 
'url' => 'somesite2.com', 
'img' => 'image2.jpg', 
'ttl' => 'Tool Tip 2', 
'alt' => 'Alt Text 2' 
), 
3 => array( 
'url' => 'somesite3.com', 
'img' => 'image3.jpg', 
'ttl' => 'Tool Tip 3', 
'alt' => 'Alt Text 3' 
), 
4 => array( 
'url' => 'somesite4.com', 
'img' => 'image4.jpg', 
'ttl' => 'Tool Tip 4', 
'alt' => 'Alt Text 4' 
), 
5 => array( 
'url' => 'somesite5.com', 
'img' => 'image5.jpg', 
'ttl' => 'Tool Tip 5', 
'alt' => 'Alt Text 5' 
), 
); 
?>  <?php 
/* 
* PART 2 - THE OUTPUT 
* This is simple, simply place the link/image line where needed. 
* I included the path as a fixed part in this example 
* I added an optional container div. Image string is XHTML. 
* Note that the ?> of the last part and <?php of this part 
* can be removed if you decide to combine the two sections. 
* Also note that contstant variables like path (shown) and 
* height and width dimensions can be added below and removed 
* from the section above if that better meets your needs 
*/  $ad = array_rand($ad_rand); 
echo(' 
<div> 
<a href="http://'.$ad_rand[$ad]['url'].'/" title="'.$ad_rand[$ad]['ttl'].'"> 
<img src="http://images.cnblogs.com/'.$ad_rand[$ad]['img'].'" width="468" height="60" alt="'.$ad_rand[$ad]['alt'].'" /> 
</a> 
</div> 
'); 
?> 

PHP随机生成广告图片的实例 代码的更多相关文章

  1. JS随机生成不重复数据的代码分享

    JS随机生成不重复数据. 代码如下: <script> // 定义存放生成随机数的数组 var array=new Array(); // 循环N次生成随机数 for(var i = 0 ...

  2. Django随机生成验证码图片

    PIL简介 什么是PIL PIL:是Python Image Library的缩写,图像处理的模块.主要的类包括Image,ImageFont,ImageDraw,ImageFilter PIL的导入 ...

  3. php随机生成验证图片

    为了防止用户利用机器人自动注册.登录.灌水,现在网站一般都采用了验证码技术,就是将一串随机产生的数字或符号,生成一幅图片,图片里加上一些干扰象素(防止OCR),由用户肉眼识别其中的验证码信息,输入表单 ...

  4. 【Javascript + Vue】实现随机生成迷宫图片

    前言 成品预览:https://codesandbox.io/s/maze-vite-15-i7oik?file=/src/maze.js 不久前写了一篇文章介绍了如何解迷宫:https://www. ...

  5. java实现随机验证码的图片

    链接地址:http://blog.sina.com.cn/s/blog_407a68fc010006qo.html 1.一共需要2个常用java文件(RandomCode.java和RandomCod ...

  6. php生成文字图片效果

    php生成文字图片效果最近看到php的GD功能,试着做了一个基本生成文字图片效果的代码: 显示文字图片页面:demo.php<?php$str = $_REQUEST['str'] ? $_RE ...

  7. 随机生成四则运算式2-NEW+PSP项目计划(补充没有真分数的情况)

    PS:这是昨天编写的随机生成四则运算式2的代码:http://www.cnblogs.com/wsqJohn/p/5264448.html 做了一些改进. 补:在上一次的运行中并没有加入真分数参与的运 ...

  8. ThinkPHP5.0图片上传生成缩略图实例代码

    很多朋友遇到这样一个问题,图片上传生成缩略图,很多人在本机(win)测试成功,上传到linux 服务器后错误. 我也遇到同样的问题.网上一查,有无数的人说是服务器临时文件目录权限问题. 几经思考后,发 ...

  9. php随机生成验证码代码

    <?php session_start(); //产生一个随机的字符串验证码 $checkcode=""; for ($i=0;$i<4;$i++){ $checkco ...

随机推荐

  1. 读logback源码系列文章(五)——Appender --转载

    原文地址:http://kyfxbl.iteye.com/blog/1173788 明天要带老婆出国旅游几天,所以这段时间暂时都更新不了博客了,临走前再最后发一贴 上一篇我们说到Logger类的inf ...

  2. C语言结构体和联合体

    1.单链表插入 #include <stdio.h> #include <stdlib.h> #define FALSE 0 #define TRUE 1 typedef st ...

  3. jsp自定义标签分页

    第一步:建立分页实体page类 package com.soda.util; /** * @description 分页实体类 * @author line * @time 2016年8月28日11: ...

  4. java中的静态方法

    静态方法是属于类的,内存必须为它分配内存空间,这个空间一直由静态方法占用,内存管理器不会由于静态方法没有被调用而将静态方法的存储空间收回,这样如果将所有的方法都声明为静态方法,就会占用大量的内存空间, ...

  5. set_ip_pool

    #! /usr/bin/env python# -*- coding: utf-8 -*- import redisimport urllib2class RedisConnect:    #clas ...

  6. ES 父子文档查询

    父子文档的特点 1. 父/子文档是完全独立的. 2. 父文档更新不会影响子文档. 3. 子文档更新不会影响父文档或者其它子文档. 父子文档的映射与索引 1. 父子关系 type 的建立必须在索引新建或 ...

  7. MSP430常见问题之复位系统类

    Q1:请问msp430 怎么手动复位啊?是不是连到RST/NMI 上?但是这个脚不是和JTAG 连吗?我看到一些资料上说复位的话还要上拉电阻或者复位电路.A1:JTAG 功能只在下载程序时候使用,正常 ...

  8. 【模拟ACM排名】ZOJ-2593 Ranking (Andrew Stankevich’s Contest #5)

    真心是道水题,但找bug找的我想剁手了/(ㄒoㄒ)/~~ 注意几个坑点, 1.输入,getline(cin); / gets(); 一行输入,注意前面要加getchar();   输入运行记录的时候可 ...

  9. BOOTCAMP版本适配机型表

    这些只支持64位的win7 win8 ******************************************** 5.1.5640 MacBook Air(11 英寸,2013 年中)M ...

  10. 关于IE6的一些常见的CSS BUG处理

    CSS BUG:样式在各浏览器中解析不一致的情况,或者说CSS样式在浏览器中不能正确显示的问题称为CSS BUG: CSS Hack:css hack是指一种兼容css 在不同浏览器中正确显示的技巧方 ...