亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

PHP隨機生成廣告圖片的實例分享

標簽:
PHP

php随机生成图片:


<?php /*+------------------------------------------------------------------+| MikeCherim.com || PHP: Ad Generator || PHP Hypertext Preprocessor || Copyright Dec 2006 || Use with attribution by visible link please! || Attribute to: <a >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.*/ www.jbxue.com?><?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.*/$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>');?>


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消