Porting Aid for dealing with the problem that some PHP's have ImageGIF(), others have ImagePNG()

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@34111 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Martin Kraemer 2000-10-19 09:23:47 +00:00
parent a4c5921206
commit 9b53d281d7

View file

@ -1058,6 +1058,33 @@ function LoadPNG ($imgname) {
<acronym>GD</acronym> library in version 1.6, this function is
not available if you are using that version of the GD library.
</para>
<para>
The following code snippet allows you to write more
portable PHP applications by auto-detecting the
type of GD support which is available. Replace
the sequence <literal>Header("Content-type: image/gif");
ImageGif($im);</literal> by the more flexible sequence:
<informalexample>
<programlisting role="php">
&lt;?php
if(function_exists("imagegif")) {
Header("Content-type: image/gif");
ImageGif($im);
}
elseif(function_exists("imageJpeg")) {
Header("Content-type: image/jpeg");
ImageJpeg($im, "", 0.5);
}
elseif(function_exists("imagePng")) {
Header("Content-type: image/png");
ImagePng($im);
}
else
die("No image support in this PHP server");
?&gt;
</programlisting>
</informalexample>
</para>
</note>
</para>
</refsect1>