Here are the first 4 lines on the new "strict" pages my company is using:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
problem is the string <? is picked up by PHP and is thought to be the start of a php tag. is there any way to write that first line that would get around this and still be acceptable? Thanks!
[oh, duh, I suppose I could just do this:
<?php echo '<?xml version="1.0" encoding="UTF-8"?>';?>
but still perhaps there's another way without resorting to that, thanks]
<?xml version="1.0" encoding="UTF-8"?
actually with a xhtml 1.0 strict doctype you shouldn't be using the XML prologue at all.
you need to get rid of it.
<?xml version="1.0" encoding="UTF-8"?
Get rid of that first line...
<?xml version="1.0" encoding="UTF-8"?
Yeah, get rid of the xml prolog. It will just force IE into quirks mode and cause problems anyway.
<?xml version="1.0" encoding="UTF-8"?
As above but regardless it shouldn't be causing a problem with the php script :? should it! you can only deal with html within php or php within html in one of three ways surely; you either echo/print out the html in which case it should be a string contained in quote marks '<?xml>';
or you come out of php immediately before hand ?><?xml and go back in afterwards or you use 'herdoc' syntax to allow large blocks of html unquoted within php scrip tags, sounds like there may be a fundemental flaw with the scripting, or I'm missing some point in all this
Hugo.
<?xml version="1.0" encoding="UTF-8"?
Hugo's correct. It shouldn't be messing with the php script. Most likely a server setting that is picking up "<?" as php instead of "<?php"
I haven't seen a server in a long time that accepted just the "<?" for a php script probably for this very reason.
<?xml version="1.0" encoding="UTF-8"?
I guess it's one example of why shorttags are a bad idea.
<?xml version="1.0" encoding="UTF-8"?
Hugo's correct. It shouldn't be messing with the php script. Most likely a server setting that is picking up "<?" as php instead of "<?php"
I haven't seen a server in a long time that accepted just the "<?" for a php script probably for this very reason. From php.ini, under language options,
;Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
short_open_tag = On
As I recall, that's the default. The file, if on a *nix machine compliant with the filesysytem hierarchy standard (FHS), will reside in /etc, likely as /etc/php4/apache/php.ini
As root, open in Emacs or some lesser editor and change On to Off[1]. Do a graceful restart[2] on Apache, and you're good to go. Don't forget to exit to your regular user.
cheers,
gary
[1] If you've been using short tags in your scripting, it might not be a good plan to turn it off
[2] As apposed to Windows, where you must reboot to reconfigure most applications, A graceful restart tells the application to reread the configuration files. The current page being delivered is under the old rules, the next page under the new.
<?xml version="1.0" encoding="UTF-8"?
It does appear to be the default :? I had it in mind that you had to set short tags on, all the best practise I've read is not to use them so never have
<?xml version="1.0" encoding="UTF-8"?
Back in the day, before reaching my present exalted status, I had the same problem as the OP. The simple cure, as I learned, was not to use the xml declaration.
cheers,
gary
<?xml version="1.0" encoding="UTF-8"?
Oh exalted one, surely the real answer is not to use the shorttag as often and repeatedly advised by dem learned people, it's why I was confused as to why there was a problem in the first place, didn't cross my mind that shorttags were the cause, but we know I'm slow on the uptake, is there actually any really good reason to use them? other than saving the typing of three characters.
Hugo.
<?xml version="1.0" encoding="UTF-8"?
Hmmm. A question worthy of the guru. But I will allow my 6 year old granddaughter to answer.
Hi uncle Yugo,
The short taggies won't hurt anything, but the eximel decoration will.
bye,
Emma
<?xml version="1.0" encoding="UTF-8"?
I see Emma thing is though you could run into problems if you wanted your scripts to be portable, the problem is that this short tag feature is a 'feature' even if it is enabled by default it remains something that is in addition to the actual way things would work if that feature were turned off, so one could run into the problem of moving a script to a server that had shortags disabled, now where would we be? up the swany I believe is the expression, navigating a certain creek without a paddle with which to escape.
Of course it may also be considered that to remove a perfectly valid piece of code due to the fact that it conflicted with anothers syntax whilst that other syntax was in fact not a required or natural one would not be good practise.
Nothing good ever comes of shortcuts, they make us lazy one must always strive to do things in their fullest there are no shortcuts in life
Now if you would be so good as to pass this on to your grandaddy but be gentle with him he's set in his ways and it may take a while for him to unlearn bad practises, it comes with age I'm afraid Emma
but as you can see now these shorttaggies can be nasty horrible things and you should not play with them
<?xml version="1.0" encoding="UTF-8"?
... these shorttaggies can be nasty horrible things and you should not play with them
<?xml version="1.0" encoding="UTF-8"?
I normally have short tags off. For templates I'll use apache to turn them on. It keeps template files shorter and neater.
<?xml version="1.0" encoding="UTF-8"?
But that was one of my queries; what benefit to it's use, does it really keep things neater ? if one is going in and out of php all the time does it not help to focus the eye to where all the starts and stops are if one has a clear <?php , does it really save space/time
<?xml version="1.0" encoding="UTF-8"?
I think so.
Even in my templates I'll use <?php for whole lines of php code. Its much easier to display a variable with <?=$var?> than <?php echo $var?> and in particular makes lines in forms much simpler
<input id="<?=$id?>" name="<?=$name?>" <?=$class?> type="checkbox" <?=$enabled?> value="<?=$value?>" <?=$checked?> />
<?xml version="1.0" encoding="UTF-8"?
Dear uncle Yugo,
My grandaddy says bollocks. I don't know what that means. He said you know. He says just because shorty tag things are there doesn't mean you have to use them. He says that about playing in the street too.
My mommy and daddy just got new sod on the front yard. Why does grandaddy say you should sod off. Don't you want a pretty lawn?
Mommy says we have to go now.
Bye,
Emma
<?xml version="1.0" encoding="UTF-8"?
Er, . . . what?
<?xml version="1.0" encoding="UTF-8"?
Hi Emma, grandaddy is just being cantankerous and irascible which just means he's a little grumpy which comes when one reaches ones senior years, but Emma you must not repeat that word to mommy or daddy because your grandaddy will be in a lot of trouble and probably won't be allowed to watch his favorite programme or have his cocoa at bedtime.
Your grandaddy was encouraging - as spring is now upon us - to get out in the garden and sod the lawn, but I do pay particular attention to the lawn and am often heard to remark "sod the lawn" , I trust too that your grandaddy has sodded off to the garden as well, if not could you ask him to withdraw his finger and see to some real work, but make sure he takes his zimmer frame, we don't want him having an accident.
Regarding the shortytagies Emma the problem is that it's not a question of taking a deliberate decision to use them but that they are enabled by default which strikes me as odd, it would make more sense that if you want to use them you should have to deliberately enable them.
I do see though that there is a an benefit as demonstrated by Chris's code example and confess that I had overlooked the shorthand <?= that would make a difference to those html tags where every attribute becomes a variable and thus ends up becoming unnaturally long and hard to read.
meanwhile, back at the beginner's forum..
meanwhile, back at the beginner's forum, the "OP" (a new acronym I learned), wonders why a certain question wasn't mentioned/answered, see below:
<div id="obviousQuestion :-)" style="display:none;" onClick="document.getElementById('obviousQuestion :-)').style.display='block';">
why should I not use the xml declaration when the wc3 page I read showed it there? I'd appreciate knowing.
</div>
oops, sorry - you can't click on the div because it has no dimensions..
Re: meanwhile, back at the beginner's forum..
why should I not use the xml declaration when the wc3 page I read showed it there? I'd appreciate knowing.
it forces IE into quirks mode
<?xml version="1.0" encoding="UTF-8"?
For IE (what else).
IE requires a proper doctype to get into standards mode - where it at least tries to behave like a decent browser. For IE the doctype must be the first thing in the html page. Anything before it, like, for example, "<?xml ... " leaves IE in quirks mode.
For XHTML1 the "<?xml ... " is not required unless you are doing something strange with character sets or some other xml only stuff (I think the xhtml spec has the details of when it is required).
<?xml version="1.0" encoding="UTF-8"?
Samf the xml declaration wasn't expounded on probably due to the fact that every other post has to make mention of it, you have 66 posts to your name I would have assumed that you had seen sight of one of the explanations abound on the forum or perhaps perused the 'How to' section where I think it is mentioned as well, it's a very well known problem. A simple google on 'using xml prolog' will list four entries on the first page dealing with said problem.
Hugo.
<?xml version="1.0" encoding="UTF-8"?
A simple google on 'using xml prolog' will list four entries on the first page dealing with said problem.
