I have a .php with <?xml version="1.0" encoding="utf-8"?> in it, not in inside of <?php ?>, but I get an error, because php is trying to read it as short tags, so how can I get it to be parsed as html? I don't want to have to put it in <?php and then echo it
Only simple way I know of: <?= '<' . '?xml version="1.0" encoding="utf-8"?' . '>' ?> Code (markup): I know you specifically said you didn't want to echo it. The only other way would be to store the tags in a seperate file from your script, read the file in and send it straight to output. That way the tags wouldn't be parsed.
You can use heredoc syntax for that, all data will be outputted "as is": <? echo <<<EOL <?xml version="1.0" encoding="utf-8"?> EOL; echo 'code'; ?> PHP: But I would recommend using templates to separate your presentation layer and code. Simple solution also is a file inclusion: header.xml contents: <? include 'header.xml'; echo 'code'; ?> PHP:
$questionmark = "?"; echo "<".$questionmark."xml version=\"1.0\" encoding=\"utf-8\"".$questionmark.">"; PHP:
^^ If he wanted to echo it, he could do: echo '<?xml version="1.0" encoding="utf-8"?>'; PHP: But he doesn't want to echo it...