一个PHP群友搞的智力问答题:
看看在PHP中有多少种方法不用echo/print来输出数据,大家来一起发散思维一下。
先举三个例子:
1. $output = fopen('http://www.copterfly.cn/1.txt', 'w');
fputs($output, $text);
2.$myVar = 'Copterfly的博客';
var_dump($myVar);
3.die("出错啦!");
群友回答如下:
print_r('123');
exit('123');
throw new Exception(http://www.copterfly.cn);
这个用GD来输出的强:
<?php
header ("Content-type: image/png");
$im = @imagecreatetruecolor(51, 20) or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 255, 255, 255);
imagestring($im, 2, 5, 3, "Copterfly's Blog", $text_color);
$text_color = imagecolorallocate($im, 246, 122, 48);
imagepng($im);
imagedestroy($im);
?>
ini_set('display_errors','on');
error_reporting(E_ALL);
trigger_error('Copterfly',E_USER_NOTICE);
你能添点么?



