php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21497 include() of XML document fails
Submitted: 2003-01-07 13:15 UTC Modified: 2003-03-25 15:28 UTC
From: polone at townnews dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.0 OS: RedHat Linux 6.2
Private report: No CVE-ID: None
 [2003-01-07 13:15 UTC] polone at townnews dot com
When using the include(), include_once(), require(), or require_once() functions, documents beginning with:

<?xml version="1.0"?>

fail to be loaded. I'm guessing this might have to do with PHP trying to interpret the <?xml as <?php, causing a fatal error. Proper operation should check for the processing instruction (PI) value of <?, that is:

<? or <?php

maybe interpreted as PHP, but not,

<?some_other_text

at the very least, not:

<?xml

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-07 13:17 UTC] edink@php.net
Disable short_open_tags in your php.ini and the problem will go away.
 [2003-01-07 14:17 UTC] polone at townnews dot com
That does fix the problem, but enabling short open tags shouldn't invalidate properly formatted processing instructions for something other than PHP.

In addition, this cannot be altered or disabled by ini_set() from a PHP script (perhaps a security risk?) at run-time.
 [2003-03-24 20:29 UTC] mike at sydel dot net
I am also experiencing this problem.  Indeed, polone is right that disabling short tags shouldn't be the solution.  I say this because a lot of people are already using <?=$var?> to simply echo variables.  If they for one case also encountered the same problem as we have, then he has to rewrite the code where <?= is located.

Besides, short tags is a feature that helps a lot.
 [2003-03-25 09:16 UTC] jtate@php.net
This will not be fixed by any current member of the PHP development group.  If you desire a fix, submit a patch (though some have already tried and haven't been sucessfull in getting the patches accepted), otherwise, remove all your short tags.  There are a number of problems with using short tags, and therefore reasons that you shouldn't use them in your code.  The most prominent is that using short tags makes your code essentially non-portable.  This from the current php.ini:

; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.  
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.

 [2003-03-25 11:05 UTC] mike at sydel dot net
argument seems valid.  guess, i just have to make one big search and replace on all my code and replace
<?=
with
<?php=

:-)

Thanks.
 [2003-03-25 11:08 UTC] mike at sydel dot net
oh i forgot!

this however still does not solve the problem of <?xml...

many php hosting providers enable short tags.

anyway, guess that's their problem.  other than that, i just have to look for workarounds since ini_set doesn't appear to work.
 [2003-03-25 15:28 UTC] jay@php.net
There's no such thing as <?php=, just <?=. You'll have to 
use "<?php echo" or something.  
 
J 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 18:01:29 2024 UTC