Laravel 5.3 dd()输出为纯文本

时间:2017-09-07 14:33:22

标签: php debugging curl laravel-5

当我在我的控制器和dd()中创建一个新的空集合时,我得到了一个很好的结果:

Collection {#205 ▼
  #items: []
}

但是当我在那之后进行cURL调用并且dd()之后,输出以纯文本显示(截断):

<script> Sfdump = window.Sfdump || (function (doc) { var refStyle = doc.createElement('style'), rxEsc = /([.*+?^${}()|\[\]\/\\])/g, idRx = /\bsf-dump-\d+-ref[012]\w+\b/, keyHint = 0 <= navigator.platform.toUpperCase().indexOf('MAC') ? 'Cmd' : 'Ctrl', addEventListener = function (e, n, cb) { e.addEventListener(n, cb, false); }; (doc.documentElement.firstElementChild || doc.documentElement.children[0]).appendChild(refStyle); if (!doc.addEventListener) { addEventListener = function (element, eventName, callback) { element.attachEvent('on' + eventName, function (e) { e.preventDefault = function () {e.returnValue = false;}; e.target = e.srcElement; callback(e); }); }; } function toggle(a, recursive) { var s = a.nextSibling || {}, oldClass = s.className, arrow, newClass; if ('sf-dump-compact' == oldClass) { arrow = '&#9660;'; newClass = 'sf-dump-expanded'; } else if ('sf-dump-expanded' == oldClass) { arrow = '&#9654;'; newClass = 'sf-dump-compact'; } else { return false; } a.lastChild.innerHTML = arrow; s.className = newClass; if (recursive) { try { a = s.querySelectorAll('.'+oldClass); for (s = 0; s < a.length; ++s) { if (a[s].className !== newClass) { a[s].className = newClass; a[s].previousSibling.lastChild.innerHTML = arrow; } } } catch (e) { } } return true; };

这是我的代码:

$collection = collect();
// dd( $collection );

header("Content-type: application/json");
$token
$url = "https://example.org";
$param= "authtoken=".$token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
$result = curl_exec($ch);
curl_close($ch);

dd( $collection );

有谁知道造成这种情况的原因是什么?这与cURL电话有什么关系吗?

1 个答案:

答案 0 :(得分:3)

问题在于行:

header("Content-type: application/json");

这将使浏览器期望JSON字符串作为响应,因此不会执行任何脚本或呈现任何HTML。

删除此行将再次根据dd

的输出格式化结果