首页 技术 正文
技术 2022年11月6日
0 收藏 588 点赞 639 浏览 2542 个字

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/" rel="external nofollow" >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'].'/" rel="external nofollow"  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> 
'); 
?> 
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,091
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,568
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,416
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,188
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,825
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,908