Solution to the problem that php cannot output gif: 1. Modify "php.ini" in the directory where php is located; 2. Download "php_gd_gif.dll" that supports generating dynamic gif; 3. Modify the program or "php. ini".
The operating environment of this article: windows7 system, php4.05 version, DELL G3 computer
Problems encountered when using PHP to dynamically generate gif and Solution
PHP does not specify to only output html files, it can generate dynamic gif files. I encountered some problems when using php to dynamically generate gif images. They have been solved. I am using php4.05 (for win32) apache3.1.2_win32.
Question 1:
The program that dynamically generates gif cannot be used to access MongoDB files. I wrote an example about using php to generate gif. After running it, I found The page just cannot be refreshed, as if it is dead, and the browser does not give any error prompts.
Solution:
Modify php.ini in the directory where php is located
Modify php.ini in the path where php is installed (note: it must be php in the php path .ini) extension_dir = the path to install php extensions (for example: c:phpextensions).
Question 2:
php_gd.dll does not support gif
I loaded the php_gd.dll dynamic link library at the beginning of the program: dl(" php_gd.dll"); But when running the program, this result appeared:
<br><b>Warning</b>: ImageGif: No GIF support in this PHP build in <b>d:apachehtdocsgif2.php3</b> on line <b>12</b><br>。
Solution:
Use php4.05
That’s when I discovered The problem written in the book is that php_gd.dll cannot support generating gif at all. After being guided by an expert, I found out that my version of php4.04 for win32 lacks php_gd_gif.dll, so I downloaded a higher version of php4.05. Here is There is php_gd_gif.dll that supports generating dynamic gifs.
Question 3:
A warning appears: Warning: Function registration failed – duplicate name – imagearc in d:apachehtdocsgif2.php3 on line 3
Program As follows:
<? dl("php_gd_gif.dll"); header("content-type:image/gif"); $im = imagecreate(400,30); $black = imagecolorallocate($im,0,0,0); $white = imagecolorallocate($im,255,255,255); imageline( $im,200,15,215,15,$white); imagestring($im, 5, 4, 10, "This is a Gif", $white); imagegif($im); imagedestroy($im); ?>
Solution:
Modify the program or php.ini
dl() function is used to load dll, but if in the php.ini file If the ";" in front of the required dll has been removed, then do not use this function at this time.
If the ";" before extension=php_gd_gif.dll in the ini file is not removed, then dl("php_gd_gif.dll"); must be used to load it. In short: the two are different from each other, otherwise the server Considered a duplicate naming.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What to do if php cannot output gif. For more information, please follow other related articles on the PHP Chinese website!

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

查找方法:1、用strpos(),语法“strpos("字符串值","查找子串")+1”;2、用stripos(),语法“strpos("字符串值","查找子串")+1”。因为字符串是从0开始计数的,因此两个函数获取的位置需要进行加1处理。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download
The most popular open source editor

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver Mac version
Visual web development tools