我找到了这个包,我正在尝试运行示例和显示括号。
但它输出了一些奇怪的字符:
�PNG IHDR�Ht�4PLTE���U��~�IDATx����o�V��GIW&q�*�=ު`B�&��?�?!R*Mv�
你明白了。
我认为这是因为:
// If GD-lib is installed, the below code will draw the bracket of the knock-out tournament.
if ($GDLIB_INSTALLED) {
$im = $KO->getImage("Tournament name here");
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
}
但我不知道该怎么修…
谢谢,Ara
编辑:
所以我在gat说了之后稍微修改了一下代码。
在我的控制器中,我得到:公共函数getTest(){
// Depending on whether or not GD-lib is installed this example file will output differently.
$GDLIB_INSTALLED = (function_exists("gd_info")) ? true : false;
// Lets create a knock-out tournament between some of our dear physicists.
$competitors = array(
'Paul A.M. Dirac',
'Hans Christian Oersted',
'Murray Gell-Mann',
'Marie Curie',
'Neils Bohr',
'Richard P. Feynman',
'Max Planck');
// Create initial tournament bracket.
$KO = new TournamentGeneratorGD($competitors);
$KO->setResByMatch(1, 1, 4, 0);
if($GDLIB_INSTALLED){
$im = $KO->getImage("Tournament name here");
return View::make('test_img')
->with('im', $im);
}
else
return View::make('home');
}
在我的test_img.php页面中,我得到了以下内容:
<?php
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
无论如何它都不起作用。。
header('Content-type: image/png');
应该是在输出其他内容之前说的第一句话。
尝试将以下代码移动到另一个源文件(img.php或其他文件)。
header('Content-type: image/png');
$im = $KO->getImage("Tournament name here");
imagepng($im);
imagedestroy($im);
然后,您可以将页面重定向到if ($GDLIB_INSTALLED)
块中的img.php。