2012-10-02 4 views
0

Im은 PHP 매뉴얼을 참조하지만 Im은 초기 닫기 PHP 태그로 인해 구문 오류가 발생합니다. 분명히 Im은 PHP이지만 new는 PHP 문자열로 xml을 지정하려고 시도합니다. 뭐가 문제 야?PHP SimpleXML 사용법에 대한 구문 설명

<?php 
$xmlstr = <<<XML //Need a clarification on '<<<XML' if possible 
<?xml version='1.0' standalone='yes'?> //This is closing my php script and causing error 
<details> 
<detail> 
    <user>mcgraw</user> 
    <dateA>09/11/1973</dateA> 
    <inTime>9:00am</inTime> 
    <outTime>6:00pm</outTime> 
    <hours>9</hours> 
    <notes>Monday</notes> 
</detail> 
<detail> 
    <user>simpson</user> 
    <dateA>08/23/1983</dateA> 
    <inTime>9:00am</inTime> 
    <outTime>5:30pm</outTime> 
    <hours>8.5</hours> 
    <notes>Thursday</notes> 
</detail> 
</details> 
XML; 
?> 
+0

정확한 오류 메시지를 알려주시겠습니까? – Ariel

+0

오류를 신호하는 유일한 방법은 구문 강조입니다. Dreamweaver php 태그가 열리고 닫힙니다. xml heading closing 태그가 닫는 PHP 태그로 읽혀지고 빨간색으로 작성됩니다. 이것은 드림위버 문제 일뿐입니까? – mcgraw

답변

3

PHP의 Heredoc 구문이라고합니다. 인용문을 걱정하지 않고 문자열을 마크 업하는 데 도움이됩니다.

더 간단한 예는 다음과 같습니다

$string = <<<STR_END_DELIMITER 
This is some string, I can use ' and " freely, and it wouldn't break the string. 
I can also use $variables inside, and they'll evaluate. 
When I'm done with the string, I'll need to type STR_END_DELIMITER; on a fresh line, without anything else (not even spaces!) 
STR_END_DELIMITER; 
do_stuff_with_string($string); 

자세한 내용은 PHP Manual Entry on Strings를 참조하십시오.

+0

내 문법에 따르면 괜찮아요.하지만 <---- PHP 스크립트의 닫는 태그로 사용되기 때문에 CS6 Dreamweaver에서 오류가 발생합니다. 다음 코드는 보이지 않습니다. – mcgraw

+3

@ mcG73 php에서 오류가 발생하지 않고 오류가 Dreamweaver에서 강조 표시된 구문 오류 인 경우 Dreamweaver에서 문자열 구문을 인식하지 못할 가능성이 높습니다. – Gavin

+0

@ mcG73 : 내 PHPStorm은 이러한 오류를 발생시키지 않으며 페이지를 실행할 때 PHP도 실행하지 않습니다. –