使用PHP GD庫繪製映像,不顯示的問題

來源:互聯網
上載者:User

標籤:function   關閉   style   判斷   oca   blog   hit   繪製映像   安裝   

1. 使用PHP中的GD庫繪製映像,之後瀏覽器無法顯示,GD庫安裝,配置也沒什麼錯誤,提示映像因本身有錯無法顯示,於是就在header() 前面使用ob_clean();然後使用瀏覽器就能正常的瀏覽了

 1 <?php 2 $height = 300; 3 $width = 300; 4 $im = imagecreatetruecolor($width, $height); 5 $white = imagecolorallocate ($im, 255, 255, 255); 6 $blue = imagecolorallocate ($im, 0, 0, 64); 7 imagefill($im, 0, 0, $blue); 8 imagestring($im, 10, 100, 120, ‘Hello,PHP‘, $white); 9 ob_clean();10 header (‘Content-type: image/png‘);11 imagepng($im);imagedestroy($im);12 ?>

ob_get_contents() - 返回輸出緩衝區的內容

ob_flush() - 沖刷出(送出)輸出緩衝區中的內容

ob_clean() - 清空(擦掉)輸出緩衝區

ob_end_flush() - 沖刷出(送出)輸出緩衝區內容並關閉緩衝

ob_end_clean() - 清空(擦除)緩衝區並關閉輸出緩衝

flush() - 重新整理輸出緩衝

 

2. 判斷GD庫是否安裝

使用函數fnction_exists()

1 if(function_exists(‘imagecreate‘)){2 3    echo"已成功安裝";4 5 }

 

使用PHP GD庫繪製映像,不顯示的問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.