2017-09-07 3 views
0

는, 나는 좋은 결과를 얻을 :Laravel 5.3 DD() 출력

Collection {#205 ▼ 
    #items: [] 
} 

을하지만 컬 호출 및 dd()을 할 때 컬렉션 그 후, 출력 내용 (일부) 일반 텍스트로 표시됩니다

$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); 
:

<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; }; 

이 내 코드입니다

누군가이 문제의 원인을 알고 있습니까? 그것은 cURL 호출과 관련이 있을까요?

+0

의 출력에 따라 결과를 포맷합니다이 줄을 제거

은 생성하고 해당 스크립트를 실행의 결과는 마크 업. – apokryfos

+0

두 상황 모두에서 소스 코드를 살펴본 결과, 나는 그 사실을 알아 차렸다. 하지만 내가 이해할 수없는 것은 결과가 두 번째 상황에서 서식이 지정되지 않은 이유이지만 모든 코드가 일반 텍스트로 페이지에 표시됩니다. – Doc

+1

'header ("Content-type : application/json");이 (가) 웹 페이지가 아닌 JSON을 아마도 기대하고 있습니다. – apokryfos

답변

1

문제는 라인이다 :

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

이 브라우저는 응답과 같은 JSON 문자열을 기대하게됩니다 따라서 어떤 스크립트를 실행하거나 HTML 렌더링되지 않습니다. 다시 브라우저에 표시되는 내용은`dd` 출력이 실제로 어떻게 생겼는지의 dd