日期:2014-05-17  浏览次数:20599 次

帮助文档里的事例输出乱码 请求教
这是从帮助文档上考下来的事例 但为什么输出是乱码呢 怎么解决
PHP code

<?php
  header("Content-type: image/jpeg");
  $im = imagecreate(400,30);
  $white = imagecolorallocate($im, 255,255,255);
  $black = imagecolorallocate($im, 0,0,0);

  // Replace path by your own font path
  imagettftext($im, 20, 0, 10, 20, $black, "/path/arial.ttf",
  "Testing... Omega: &amp;#937;");
  imagejpeg($im);
  imagedestroy($im);
?>



输出结果:

Warning: imagettftext() [function.imagettftext]: Invalid font filename in F:\wamp\www\bkqs\imageCode\file.php on line 9
?JFIF>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality C    $.' ",#(7),01444'9=82<.342C  2!!22222222222222222222222222222222222222222222222222?" ?}!1AQa"q2亼?#B绷R佯$3br? %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz儎厗噲墛挀敃枟槞殺¥ウЖ┆渤吹斗腹郝媚牌侨墒矣哉肿刭卺忏溴骁栝犟蝮趱鲼? ?w!1AQaq"2?B憽绷 #3R?br?$4??&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz們剠唶垑姃摂晼棙櫄ⅲぅΗī炒刀犯购旅呐魄壬室釉罩棕仝忏溴骁栝牝篝貊鼬 ?鼹( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (?? 


------解决方案--------------------
错误不是很明显吗?
Warning: imagettftext() [function.imagettftext]: Invalid font filename in F:\wamp\www\bkqs\imageCode\file.php on line 9
------解决方案--------------------
Invalid font filename
字体文件位置不正确。

试试这样。
imagettftext($im, 20, 0, 10, 20, $black, dirname(__FILE__) . "/../path/arial.ttf",