php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #39169 imagecolorallocate example uses incorrect snytax for imagecreate
Submitted: 2006-10-16 19:13 UTC Modified: 2006-10-16 19:27 UTC
From: neothermic at neothermic dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: neothermic at neothermic dot com
New email:
PHP Version: OS:

 

 [2006-10-16 19:13 UTC] neothermic at neothermic dot com
Description:
------------
In a related bug to #36447, imagecolorallocate has this example:

<?php

$im = imagecreate('example.jpg', 100, 100);

// sets background to red
$background = imagecolorallocate($im, 255, 0, 0);

// sets some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);

// hexadecimal way
$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);

?> 

However, imagecreate has this syntax:
resource imagecreate ( int x_size, int y_size )

Ergo the first call in the example will issue an error. 

Suggested fix is as simple as ever:

$im = imagecreate(100, 100);

NeoThermic


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-16 19:27 UTC] colder@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2020-02-07 06:11 UTC] phpdocbot@php.net
Automatic comment on behalf of colder
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=583929f6e8494cb0824fd1288d2f7ebe7a2736db
Log: Fix #39169 (incorrect parameters for imagecreate)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Nov 20 21:00:01 2025 UTC