php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #49969 imagecolorat sample error
Submitted: 2009-10-23 10:11 UTC Modified: 2009-10-23 10:26 UTC
From: admin at ifyouwantblood dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2009-10-23 10:11 UTC] admin at ifyouwantblood dot de
Description:
------------
In the sample code on imagecolorat() the function imagecolorsforindex() is missing an argument, the image resource. See the man page for imagecolorsforindex:

array imagecolorsforindex  ( resource $image  , int $index  )

Reproduce code:
---------------
<?php
$im = imagecreatefrompng("php.png");
$rgb = imagecolorat($im, 10, 15);

list($r, $g, $b, $alpha) = imagecolorsforindex($rgb);

var_dump($r, $g, $b, $alpha);

Expected result:
----------------
<?php
$im = imagecreatefrompng("php.png");
$rgb = imagecolorat($im, 10, 15);

list($r, $g, $b, $alpha) = imagecolorsforindex($im, $rgb);

var_dump($r, $g, $b, $alpha);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-23 10:24 UTC] svn@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&revision=289884
Log: Fixed broken example. Closes #49969
 [2009-10-23 10:26 UTC] salathe@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.

Thanks for the note about the missing parameter. Also note that imagecolorsforindex returns an associative array (so the call to list would not work). I have amended the example on both counts. Thanks for the bug report.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 11:00:02 2026 UTC