PHP随机生成广告图片的实例 代码
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随机生成广告图片的实例 代码的更多相关文章
- JS随机生成不重复数据的代码分享
JS随机生成不重复数据. 代码如下: <script> // 定义存放生成随机数的数组 var array=new Array(); // 循环N次生成随机数 for(var i = 0 ...
- Django随机生成验证码图片
PIL简介 什么是PIL PIL:是Python Image Library的缩写,图像处理的模块.主要的类包括Image,ImageFont,ImageDraw,ImageFilter PIL的导入 ...
- php随机生成验证图片
为了防止用户利用机器人自动注册.登录.灌水,现在网站一般都采用了验证码技术,就是将一串随机产生的数字或符号,生成一幅图片,图片里加上一些干扰象素(防止OCR),由用户肉眼识别其中的验证码信息,输入表单 ...
- 【Javascript + Vue】实现随机生成迷宫图片
前言 成品预览:https://codesandbox.io/s/maze-vite-15-i7oik?file=/src/maze.js 不久前写了一篇文章介绍了如何解迷宫:https://www. ...
- java实现随机验证码的图片
链接地址:http://blog.sina.com.cn/s/blog_407a68fc010006qo.html 1.一共需要2个常用java文件(RandomCode.java和RandomCod ...
- php生成文字图片效果
php生成文字图片效果最近看到php的GD功能,试着做了一个基本生成文字图片效果的代码: 显示文字图片页面:demo.php<?php$str = $_REQUEST['str'] ? $_RE ...
- 随机生成四则运算式2-NEW+PSP项目计划(补充没有真分数的情况)
PS:这是昨天编写的随机生成四则运算式2的代码:http://www.cnblogs.com/wsqJohn/p/5264448.html 做了一些改进. 补:在上一次的运行中并没有加入真分数参与的运 ...
- ThinkPHP5.0图片上传生成缩略图实例代码
很多朋友遇到这样一个问题,图片上传生成缩略图,很多人在本机(win)测试成功,上传到linux 服务器后错误. 我也遇到同样的问题.网上一查,有无数的人说是服务器临时文件目录权限问题. 几经思考后,发 ...
- php随机生成验证码代码
<?php session_start(); //产生一个随机的字符串验证码 $checkcode=""; for ($i=0;$i<4;$i++){ $checkco ...
随机推荐
- 强烈推荐240多个jQuery插件提供下载
jQuery 是继 prototype 之后又一个优秀的 Javascript 框架.其宗旨是—写更少的代码,做更多的事情.它是轻量级的 js 库(压缩后只有21k) ,这是其它的 js 库所不及 的 ...
- 无法挂载 “7.9 GB Filesystem”.
有个8G的U盘,格式化成exfat格式.插入电脑后点击盘符,弹出错误提示: 无法挂载 “7.9 GB Filesystem”. Error mounting: mount exited with ex ...
- URAL 1136 Parliament 二叉树水题 BST后序遍历建树
二叉树水题,特别是昨天刚做完二叉树用中序后序建树,现在来做这个很快的. 跟昨天那题差不多,BST后序遍历的特型,找到最后那个数就是根,向前找,比它小的那块就是他的左儿子,比它大的那块就是右儿子,然后递 ...
- 为Google Reader守夜。。。
Google的阅读器快要关闭了... 立刻截图留恋呢,以后就没机会了. 唉,真是令人惋惜. 虽然我接触Google Reader还不到一年,但是我已经习惯当连上WiFi时马上更新一下手机上的gRead ...
- MYSQL5.5和5.6参数的差异
performance_schema 在 MySQL 5.6 中默认是开启的,但相关的很多参数相比 MySQL 5.5 却是降低了,例如 performance_schema 自动调整到 445 个表 ...
- 自动恢复被挂掉的hbase region server
最近老遇到hbase的regionserver自动挂掉的情况 日志总是看不出什么原因 不得已弄了个定时任务,任务的脚本类似是: pssh -H "bluejoe1 bluejoe2...&q ...
- Android 分析工具 APKAnalyser
APKAnalyser 是 Android 静态,虚拟分析工具,用来测试和验证 Android 应用的开发工作.ApkAnalyser 是个完整的工具链,可以修改二进制应用.用户可以改装,安装,运行, ...
- android——获取ImageView上面显示的图片bitmap对象
获取的函数方法为:Bitmap bitmap=imageView.getDrawingCache(); 但是如果只是这样写我们得到的bitmap对象可能为null值,正确的方式为: imageView ...
- sql常识-INNER JOIN
SQL INNER JOIN 关键字 在表中存在至少一个匹配时,INNER JOIN 关键字返回行. INNER JOIN 关键字语法 SELECT column_name(s) FROM table ...
- 让.NET程序会说话
在开发过程中需要用到让程序自动播放语音,如果是一个一个录则太麻烦了,在开发过程中发现.NET已经自带了该功能 Type type = Type.GetTypeFromProgID("SAPI ...