2012-12-01 1 views
1

브라우저의보기 소스에서 html을 각 행에 표시하려면 어떻게합니까? 나는이 같은 템플릿을 사용하여 내 웹 페이지를 생성하는 PHP를 사용하고 있습니다 :보기 소스의 html을 각 줄에 표시하십시오.

$template = '<!DOCTYPE html>'; 
$template .= '<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">'; 
$template .= '<head profile="http://gmpg.org/xfn/11"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'; 
echo $template; 

문제는 모두 내가 브라우저에서 소스보기를 사용하여 볼 한 줄에 표시됩니다.

다른 줄에 표시하려면 어떻게해야합니까?

템플릿에서 \ r \ n을 사용해 보았지만 작동하지 않습니다.

답변

2

이 같은 PHP_EOL을 사용해야합니다

$template = '<!DOCTYPE html>' . PHP_EOL; 
$template .= '<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">' . PHP_EOL; 
$template .= '<head profile="http://gmpg.org/xfn/11"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . PHP_EOL; 
echo $template; 
+0

이 윈도우에서 작동하지 않습니다 히어 닥을 사용. 사용해야합니다. "\ r \ n"PHP_EOL 대신 \ n –

+0

확인 http://stackoverflow.com/questions/4975411/when-do-i-use-php-eol-instead-of-n-and-vice- versa-ajax-jquery-client-problem –

관련 문제