PHP new一个类的时候多出一个水平制表符是怎么回事

晓敬 晓敬 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

<?php
namespace Org\QRCode;
class QRencode {

public $casesensitive = true;
public $eightbit = false;

public $version = 0;
public $size = 3;
public $margin = 4;

public $structured = 0; // not supported yet

public $level = QRConst::QR_ECLEVEL_L;
public $hint = QRConst::QR_MODE_8;

private function __construct(){

}

//----------------------------------------------------------------------
public static function factory($level = QRConst::QR_ECLEVEL_L, $size = 3, $margin = 4)
{
ob_start();
$enc = new QRencode();
$bom = ob_get_contents();
ob_end_clean();
echo ord($bom[0]);
die(0);
$enc->size = $size;
$enc->margin = $margin;

switch ($level.'') {
case '0':
case '1':
case '2':
case '3':
$enc->level = $level;
break;
case 'l':
case 'L':
$enc->level = QRConst::QR_ECLEVEL_L;
break;
case 'm':
case 'M':
$enc->level = QRConst::QR_ECLEVEL_M;
break;
case 'q':
case 'Q':
$enc->level = QRConst::QR_ECLEVEL_Q;
break;
case 'h':
case 'H':
$enc->level = QRConst::QR_ECLEVEL_H;
break;
}

return $enc;
}

//----------------------------------------------------------------------
public function encodeRAW($intext, $outfile = false)
{
$code = new QRcode();

if($this->eightbit) {
$code->encodeString8bit($intext, $this->version, $this->level);
} else {
$code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
}

return $code->data;
}

//----------------------------------------------------------------------
public function encode($intext, $outfile = false)
{
$code = new QRcode();

if($this->eightbit) {
$code->encodeString8bit($intext, $this->version, $this->level);
} else {
$code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
}

QRtools::markTime('after_encode');

if ($outfile!== false) {
file_put_contents($outfile, join("\n", QRtools::binarize($code->data)));
} else {
return QRtools::binarize($code->data);
}
}

//----------------------------------------------------------------------
public function encodePNG($intext, $outfile = false,$saveandprint=false)
{
try {

ob_start();
$tab = $this->encode($intext);
$err = ob_get_contents();
ob_end_clean();

if ($err != '')
QRtools::log($outfile, $err);

$maxSize = (int)(QRConfig::QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin));

QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin,$saveandprint);

} catch (Exception $e) {

QRtools::log($outfile, $e->getMessage());

}
}
}
?>

上面代码在运行到die(0)处的时候多出一个水平制表符来,这个是怎么回事,求各位好友帮忙解答一下,谢谢
PHP版本:PHP Version 5.4.38 x86 用fcgid运行在64位Apache/Win7_64bit上
...全文
评论 7
收藏 已收藏
分享
返回顶部
晓敬
基础编程 21,889 成员 140,329 内容