내 HTML 내에 파일이 포함 된 PHP 스크립트가 있습니다. 이 시점에서 코드는 두 개의 탭으로 들여 쓰기됩니다. 내가 뭘하고 싶은 PHP 스크립트는 각 줄에 두 개의 탭을 추가 할 수 있습니다.어떻게 PHP 스크립트를 포함 파일의 모든 줄에 탭을 추가 할 수 있습니까?
메인 페이지 : 예를 들면 다음과 같습니다이다
<body>
<div>
<?php include("test.inc"); ?>
</div>
</body>
그리고 "test.inc"
<p>This is a test</p>
<div>
<p>This is a nested test</p>
<div>
<p>This is an more nested test</p>
</div>
</div>
내가 무엇을 얻을 :
<body>
<div>
<p>This is a test</p>
<div>
<p>This is a nested test</p>
<div>
<p>This is an more nested test</p>
</div>
</div>
</div>
</body>
내가 원하는 것은 :
을
<body>
<div>
<p>This is a test</p>
<div>
<p>This is a nested test</p>
<div>
<p>This is an more nested test</p>
</div>
</div>
</div>
</body>
include 파일에 선행 탭을 추가 할 수 있다는 것을 알고 있습니다. 그러나 VS 문서를 서식을 때 제거합니다.
+1 +1 마찬가지로, 나는 여분의 TAB을 추가 할 때 요점을 정말로 보지 못합니다. 그들은 단지 최종 결과에 어떤 방식 으로든 기여하지 않으며 단지 최종 렌더링 된 HTML에서 더 많은 공간을 차지합니다. –
'preg_replace()'를 사용하지 마십시오. str_replace()는 충분합니다. – soulmerge
당신이'echo str_replace ("\ n", "\ t \ n", "\ t". $ result)'를 의미한다고 생각하지만 여전히 저에게 도움이되었습니다. – William