에서 "\의 t":이유, "N "제거 " 연구", phalcon
$application = new Application($di);
echo str_replace(["\n","\r","\t"], '', $application->handle()->getContent());
제거 왜 "\ n", "\ r", "\ t"?
에서 "\의 t":이유, "N "제거 " 연구", phalcon
$application = new Application($di);
echo str_replace(["\n","\r","\t"], '', $application->handle()->getContent());
제거 왜 "\ n", "\ r", "\ t"?
Spangen이 지적한 것처럼, 이들은 일부 특수 '공백'문자에 대한 이스케이프 시퀀스입니다.
이 링크는 여기에 자세한 내용이 있습니다 http://us3.php.net/manual/en/language.types.string.php#language.types.string.syntax.double
를 이제 중요한 참고 : "\t", "\n"
: PHP 의도로 작동하려면, 당신은 같은 큰 따옴표로 묶해야합니다. 작은 따옴표는 이러한 이스케이프 시퀀스의 의도 된 효과를 생성하지 않습니다 : '\t', '\n'
.
더 자세히 설명하기 위해이 코드를 실행하고 결과를 볼 수 있습니다. php myfile.php
과 같은 콘솔에서 실행하면 시각적 결함이 발생할 수 있으며 브라우저에서 실행하면 '소스 코드'를 볼 필요가 있습니다.
echo "Let's test... ";
echo "Because no new line characters were added, this sentence will be printed in the same line as the previous phrase.";
echo "\n";
echo "But now a new line was added, by typing \\n enclosed in double quotes.";
echo "\n";
echo "Now, let's add a tab, between the next two words: hello \t there.";
echo "\n";
echo "Now, let's add a carriage return, which will 'force' the 'cursor' in this string to move to the beginning, thus 'splitting' this string into two. Adding it now: \r There, I just added it before this last sentence.";
echo "\n";
echo 'Finally, these special characters will not work as intended if we just enclose the string with single quotes, as done in this string: \n \t \r';
이 링크는 여기에 새로운 라인과 캐리지 리턴의 차이에 대한 자세한 내용이 있습니다 https://stackoverflow.com/a/12747850/466395
는 그래서 그래, 당신이 게시 된 원래의 코드에서, 사람이없는 str_replace를 사용하는 특수 문자를 제거() 콘솔에서 '시각적 인 결함'(의도하지 않은 잘못된 출력)을 생성하는 경향이 있기 때문입니다.
줄 바꾸기, 줄 바꿈 및 탭을 단일 공백으로 바꾸어 응용 프로그램의 세부 정보를 줄 바꿈없이 한 줄로 STD_OUT에 쓸 수 있습니다.
참고 : 해당 문자에 대한 자세한 설명을 제공해 주시면 죄송합니다. 잠시 동안 나는 그들이 당신이 무엇인지 알지 못한다고 생각했습니다 (그 경우입니까?). 하지만 네가 게시 한 원본 코드의 _ 결과는 출력을 정리하기위한 것입니다. – YOMorales
감사! 그것은 나를 더 많이 배울 수 있습니다. 내 프로젝트에서이 코드는 html을 구문 분석하지 못하게하고 이제는 문제가 해결되었습니다. – goozp