Skip to content
Advertisement

PHP Colour Not Being Acknowledged

I am doing some testing with FPDF and running into an issue. When setting a container to pull it’s colour from a pre-defined variable it is not honoring the value and I can’t see why not. Example below

This works perfectly:

$pdf->SetFillColor(131,54,112);

However when trying to pull the value from a variable, it does not honor the value

$colour = '131,54,112';
$pdf->SetFillColor($colour);

Anyone with any ideas?

Advertisement

Answer

You need to pass this values as single parameters. Split them first like this:

list($r, $g, $b) = explode(',', '131,54,112');
$pdf->SetFillColor($r, $g, $b);
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement