Bug->Doc #80168 [Opn->Ver]: Warning on using second arg for imagexbm
| From: | cmb@php.net | Date: | Thu, 01 Oct 2020 14:56:52 +0000 |
| Subject: | Bug->Doc #80168 [Opn->Ver]: Warning on using second arg for imagexbm | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17950@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80168&edit=1
ID: 80168
Updated by: cmb@php.net
Reported by: matt dot peveler at gmail dot com
Summary: Warning on using second arg for imagexbm
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
Package: GD related
Operating System: Ubuntu 18.04
PHP Version: 7.4.11
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
The docs are wrong about this. The second parameter is not
optional, but it is nullable; so you could do
imagexbm($im, null);
As of PHP 8.0.0, the second parameter is actually optional,
though.
Previous Comments:
------------------------------------------------------------------------
[2020-10-01 14:42:30] matt dot peveler at gmail dot com
Description:
------------
The documentation says that the second argument to imagexbm (like the other functions) is optional,
and that if not included, the output will be sent to stdout instead of to a file. However, on
running the test script, I get a PHP Warning about the second argument missing and nothing is
outputted to stdout. Changing the used function to imagegif (or any other variant) works as
expected.
Test script:
---------------
<?php
// Create a blank image and add some text
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
// Output the image
imagexbm($im);
// Free up memory
imagedestroy($im);
Expected result:
----------------
Output the imagexbm binary to stdout
Actual result:
--------------
PHP Warning: imagexbm() expects at least 2 parameters, 1 given in /tmp/test.php on line 9
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80168&edit=1