Does anyone knows why PHP uses '<?php' instead of '<%'
Moderator: General Moderators
Does anyone knows why PHP uses '<?php' instead of '<%'
IIRC, short version (<?) is "bad", because it conflicts with XML. However, <?php is quite a long tag for templates, and there is no <?php=. Just curious.
Re: Does anyone knows why PHP uses '<?php' instead of '&l
Where did you hear that? PHP is parsed on the server XML is text.Gambler wrote:(<?) is "bad", because it conflicts with XML.
PHP mailing lists. XML uses <? for processing instructions. So PHP sees <?, tries to parse the code after it, and gives you parsing error.Where did you hear that? PHP is parsed on the server XML is text.
Support for <% tags is already available for PHP, and you can turn it on with your ini file. That's why I mentioned it.<% is from ASP... and that's, uh, yeah, I'll refrain from my comment.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Does anyone knows why PHP uses '<?php' instead of '&l
Actually <?language is the standard, so it should be properly <?xml and <?php. It is Microsoft (as usual) that is not following the standards with <%.Gambler wrote:IIRC, short version (<?) is "bad", because it conflicts with XML.
(#10850)
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
Wow, things are so bad they break their own standards...
Short and ASP style tags are a nuisance, <?php it should always be. Can also be noted that malformed html/php using %> can also cause issues - think <table width=100%>.
Standards exist for a very good reason - so extra typing or not its generally a good idea to follow them.
Standards exist for a very good reason - so extra typing or not its generally a good idea to follow them.
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
Point being? When working in a design/development company, it's not always under your list of duties to be converting the code to acceptable xhtml.jshpro2 wrote:That is invalid xhtml, the attribute's value should be quotedMaugrim_The_Reaper wrote: <table width=100%>.
ASP tags were like that before xhtml was widely accepted and used.
Re: Does anyone knows why PHP uses '<?php' instead of '&l
Because php isn't a template.Gambler wrote:IIRC, short version (<?) is "bad", because it conflicts with XML. However, <?php is quite a long tag for templates, and there is no <?php=. Just curious.
Don't worry, there are plenty of people that will want to argue otherwise, so I'll just walk right past that line, and stand firm that it answers your question: That is *why* PHP uses <?php and not a short-tag. Because being a template isn't at all a focus, concern, or even desired role for PHP. Its a full-fledged server-side language, and the proper delim for that should be <?php.
The only time it will conflict is if you open a php file in an (x)html editor. Guess what? Its not html. Its a programming language, that can produce html.
Standards exist for a very good reason
Since PHP is pre-processor, XML standards do not apply here. Stuff like <option value="<?php echo $z; ?>"> is not valid XML anyway, and <?php is not a real processing instruction. The only worry is that PHP parser will get confused.Actually <?language is the standard
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
Yes, it is invalid. Since when did that stop it being used though?jshpro2 wrote:That is invalid xhtml, the attribute's value should be quotedMaugrim_The_Reaper wrote: <table width=100%>.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Does anyone knows why PHP uses '<?php' instead of '&l
How do you mean? You can use short echo tags but I wouldn't advise it...Gambler wrote:and there is no <?php=.
Code: Select all
<?= $foo ?>Because some servers migh have them disabled, there's also talk about them being disabled in PHP6 but I personally don't buy it. My code is scattered with them, if it can save me time while coding why the hello not? If I need to upgrade I just do a file find and replace for <?= and replace it with <?php echo
edit: hmm did you edit your thread, I was replying to your "why"
edit: hmm did you edit your thread, I was replying to your "why"
http://www.php.net/~derick/meeting-notes.html#id66jshpro2 wrote:Because some servers migh have them disabled, there's also talk about them being disabled in PHP6 but I personally don't buy it.
1. Kill "<%" but keep "<?".
2. Jani will prepare a patch that disallows mixing different open/close tags.
3. Will not add "<?php =".