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. Android & Eclipse FAQ

    一.eclipse中格式化代码快捷键Ctrl+Shift+F失效的解决办法 当我要格式化代码的时候,右键-source-format能够起效,但ctrl+shift+f不好使了. google之后来发 ...

  2. Android Service与Activity之间通信的几种方式

    在Android中,Activity主要负责前台页面的展示,Service主要负责需要长期运行的任务,所以在我们实际开发中,就会常常遇到Activity与Service之间的通信,我们一般在Activ ...

  3. CSS 实现行内和上下自适应的几种方法

    在写一个移动端网页,发现网页的头部搜索框两边各有固定宽度的按钮,搜索框可以根据宽度的变化来改变自己的宽度,达到填充的目的,也就是一种自适应吧,下面写写自己尝试的几种方法 一 利用css3 的width ...

  4. 一些网摘的hpc材料

    source from: https://computing.llnl.gov Factors determines a large-scale program's performance 4     ...

  5. LInux下socket编程学习笔记

    1.socket套接字: socket起源于Unix,而Unix/Linux基本哲学之一就是“一切皆文件”,都可以用“打开open –> 读写write/read –> 关闭close”模 ...

  6. hdu 3093 动态规划

    思路:直接引用论文的话. 暂时先不考虑“使剩下的物品都放不下”的条件,那就是求 0-1 背包的所有可行方案. 用 Fi[j]表示前 i 件物品中选若干件总体积为 j 的方案数,初始为 F0[0]=1, ...

  7. css3 选择器记

    css3 选择器 根据所获取页面中元素的不同,把css3选择器分为五大类: 基本选择器 层次选择器 伪类选择器 动态伪类选择器 目标伪类选择器 语言伪类选择器 UI元素状态伪类选择器 结构伪类选择器 ...

  8. ASP.NET MVC Partial页输出JS

    很多情况Partial是需要引用到JS的,通常做法是吧JS在引用Partial的页面中加入JS文件或者JS代码. 前阵子网上看到一段代码可以在Partial页面中添加JS,输出道引用页面. publi ...

  9. Android下使用InputStream读取文件

    在Android下使用InputStream读取文件. 如果不是从头开始读取文件,使用skip 后 在读取文件 使用read读取的长度为-1会获取不到数据. 换成RandomAccessFile 使用 ...

  10. js中小数的操作及数字类型的验证

    1.丢弃小数部分,保留整数部分js:parseInt(7/2) 2.向上取整,有小数就整数部分加1js: Math.ceil(7/2) 3,四舍五入. js: Math.round(7/2) 4,向下 ...