469,352 Members | 2,154 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

Setting of <? and <?php

Hi,

I'm now doing web programming using PHP. I need to use <?php instead of <?
for PHP scripts.

How do I configure PHP so that it can recognize <? as well??

Thanks in advance
Wing
Jul 17 '05 #1
20 4402
On 2004-01-14, wing <wi**@wing.com> wrote:
Hi,

I'm now doing web programming using PHP. I need to use <?php instead of <?
for PHP scripts.

How do I configure PHP so that it can recognize <? as well??


short_open_tag = on

But be aware, there are some issues you should be aware of when using
it.

--
http://home.mysth.be/~timvw
Jul 17 '05 #2
"Tim Van Wassenhove" <eu**@pi.be> 在郵件
news:bu************@ID-188825.news.uni-berlin.de 中撰寫...
On 2004-01-14, wing <wi**@wing.com> wrote:
Hi,

I'm now doing web programming using PHP. I need to use <?php instead of <? for PHP scripts.

How do I configure PHP so that it can recognize <? as well??
short_open_tag = on

But be aware, there are some issues you should be aware of when using
it.

Thanks for your reply but can you please specify what needs to be aware of??

Wing


--
http://home.mysth.be/~timvw

Jul 17 '05 #3
"wing" <wi**@wing.com> wrote in message news:<bu**********@news.ust.hk>...
Hi,

I'm now doing web programming using PHP. I need to use <?php instead of <?
for PHP scripts.

How do I configure PHP so that it can recognize <? as well??

Thanks in advance
Wing


Review the following section in *php.ini* file.

[SNIP]

; 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.
short_open_tag = On

[/SNIP]

You can enable or disable *short_open_tag* (<?) by writing On or Off
respectively in your php.ini file.

--
Cheers,
Rahul
Jul 17 '05 #4
wing wrote:
"Tim Van Wassenhove" <eu**@pi.be> 在郵件
news:bu************@ID-188825.news.uni-berlin.de 中撰寫...
On 2004-01-14, wing <wi**@wing.com> wrote:
Hi,

I'm now doing web programming using PHP. I need to use <?php
instead of <? for PHP scripts.

How do I configure PHP so that it can recognize <? as well??


short_open_tag = on

But be aware, there are some issues you should be aware of when using
it.

Thanks for your reply but can you please specify what needs to be
aware of??

Wing


If you're using XML, it's a pain in the ass because PHP will think that your
XML is PHP. Seriously, leave short tags off, it's bad style.
Jul 17 '05 #5
Agelmar wrote:
If you're using XML, it's a pain in the ass because PHP will think that your
XML is PHP. Seriously, leave short tags off, it's bad style.


That is the standard argument (and the only one) I always hear against
short tags, and the argument I hear against using them in a script is
that it doesn't run with short tags off otherwise.

However, since short_open_tags = on is the default setting, turning them
off is (should be) a concious effort, so noone does it without a reason.
All hosting companies I know leave the default setting, so I see
nothing wrong with using the short tags. (For one thing "<?=" looks so
much neater in a template than "<?php echo".)

If someone absolutely has to have the tags off, they can use a per-dir
setting or use one simple sed command to change a whole application to
long tags, so I don't see why I should burden myself (and the template
designers) with long tags just because the style police says so.

LLAP,
Jochen

Jul 17 '05 #6
Jochen Buennagel wrote:
Agelmar wrote:
If you're using XML, it's a pain in the ass because PHP will think
that your XML is PHP. Seriously, leave short tags off, it's bad
style.


That is the standard argument (and the only one) I always hear against
short tags, and the argument I hear against using them in a script is
that it doesn't run with short tags off otherwise.

However, since short_open_tags = on is the default setting, turning
them
off is (should be) a concious effort, so noone does it without a
reason. All hosting companies I know leave the default setting, so
I see
nothing wrong with using the short tags. (For one thing "<?=" looks so
much neater in a template than "<?php echo".)

If someone absolutely has to have the tags off, they can use a per-dir
setting or use one simple sed command to change a whole application to
long tags, so I don't see why I should burden myself (and the template
designers) with long tags just because the style police says so.

LLAP,
Jochen


Just because poor style works doesn't mean you should use it. I can forgoe
all array subscripting in C and just use arrayName + whatever*sizeof(int)
instead of arrayName[whatever] - does that mean I should? <?php will work on
all platforms. <? will not. Thus, if you care about compatibility, it's a no
brainer.
Jul 17 '05 #7
Both <?php and <? are poor style. We should all use <script
language="php"></script> instead.

Uzytkownik "Agelmar" <if**********@comcast.net> napisal w wiadomosci
news:bu************@ID-30799.news.uni-berlin.de...
Jochen Buennagel wrote:
Agelmar wrote:
If you're using XML, it's a pain in the ass because PHP will think
that your XML is PHP. Seriously, leave short tags off, it's bad
style.
That is the standard argument (and the only one) I always hear against
short tags, and the argument I hear against using them in a script is
that it doesn't run with short tags off otherwise.

However, since short_open_tags = on is the default setting, turning
them
off is (should be) a concious effort, so noone does it without a
reason. All hosting companies I know leave the default setting, so
I see
nothing wrong with using the short tags. (For one thing "<?=" looks so
much neater in a template than "<?php echo".)

If someone absolutely has to have the tags off, they can use a per-dir
setting or use one simple sed command to change a whole application to
long tags, so I don't see why I should burden myself (and the template
designers) with long tags just because the style police says so.

LLAP,
Jochen


Just because poor style works doesn't mean you should use it. I can forgoe
all array subscripting in C and just use arrayName + whatever*sizeof(int)
instead of arrayName[whatever] - does that mean I should? <?php will work

on all platforms. <? will not. Thus, if you care about compatibility, it's a no brainer.

Jul 17 '05 #8
Chung Leong wrote:
Both <?php and <? are poor style. We should all use <script
language="php"></script> instead.


Hmm... actually, that's not a bad suggestion.
Jul 17 '05 #9
Agelmar wrote:
Thus, if you care about compatibility, it's a no brainer.

I've never had any complaints yet (except from the style police).

Jul 17 '05 #10
Chung Leong wrote upsidedown:
We should all use <script language="php"></script> instead.


So would I be correct in thinking that you reckon we should take
incompetent editors into consideration? Why? Or did you just forget
the smiley? What really makes you disagree with The Manual?

--
Jock
Jul 17 '05 #11
XML use <? also

Savut

"wing" <wi**@wing.com> wrote in message news:bu**********@news.ust.hk...
Hi,

I'm now doing web programming using PHP. I need to use <?php instead of <?
for PHP scripts.

How do I configure PHP so that it can recognize <? as well??

Thanks in advance
Wing

Jul 17 '05 #12
See http://www.php.net/manual/en/function.is-sarcasm.php for more info.

Uzytkownik "John Dunlop" <jo*********@johndunlop.info> napisal w wiadomosci
news:MP************************@news.freeserve.net ...
Chung Leong wrote upsidedown:
We should all use <script language="php"></script> instead.


So would I be correct in thinking that you reckon we should take
incompetent editors into consideration? Why? Or did you just forget
the smiley? What really makes you disagree with The Manual?

--
Jock

Jul 17 '05 #13
Chung Leong wrote:
See http://www.php.net/manual/en/function.is-sarcasm.php for more info.


There are no dashes in function names, so the correct link should be
http://www.php.net/manual/en/function.is_sarcasm.php ;-)

Jochen

Jul 17 '05 #14
Chung Leong wrote upsidedown:
Uzytkownik "John Dunlop" <jo*********@johndunlop.info> napisal w wiadomosci
news:MP************************@news.freeserve.net ...
Chung Leong wrote upsidedown:
We should all use <script language="php"></script> instead.


So would I be correct in thinking that you reckon we should take
incompetent editors into consideration? Why? Or did you just forget
the smiley? What really makes you disagree with The Manual?


See http://www.php.net/manual/en/function.is-sarcasm.php for more info.


Right, OK, OK. A smiley would've helped me there! :-]

http://www.google.com/googlegroups/p...yle.html#humor
http://sic.epfl.ch/SA/News/Smiley.html

But in all earnest, your sarcastic recommendation is surely
reasonable, since AFAIK, the "<script...>" PHP tag is the only one
that is supported everywhere. I have no idea why a not-very-well-
documented, deprecated HTML notation was chosen as PHP tags though --
that'd be another discussion altogether.

The Manual says that even "<?php" won't work on editors that don't
grok processing instructions, and, <sarcasm>lo and behold</sarcasm>,
FrontPage is given as an example. That doesn't stop them from
recommending using "<?php" though. I'm with them on that.

EOD?

--
Jock
Jul 17 '05 #15
John Dunlop wrote:
The Manual says that even "<?php" won't work on editors that don't
grok processing instructions, and, <sarcasm>lo and behold</sarcasm>,
FrontPage is given as an example. That doesn't stop them from
recommending using "<?php" though. I'm with them on that.


The Manual also says about short_open_tags: "If you want to use PHP in
combination with XML, you can disable this option."

There is no other reason given for turning them off. The fact that
short_open_tags=on is the default tells me that it is the preferred
setting for most applications, so I use it until someone (except the
style-police) complains.

Jochen

Jul 17 '05 #16
But, my friend, underscores are replaced with dashes for the URL in the PHP
manual.

See http://www.php.net/manual/en/functio...t-contents.php

Uzytkownik "Jochen Buennagel" <za*********@buennagel.com> napisal w
wiadomosci news:bu*************@news.t-online.com...
Chung Leong wrote:
See http://www.php.net/manual/en/function.is-sarcasm.php for more info.


There are no dashes in function names, so the correct link should be
http://www.php.net/manual/en/function.is_sarcasm.php ;-)

Jochen

Jul 17 '05 #17
On Thu, 15 Jan 2004 23:36:34 -0500, Chung Leong hath writ:
See http://www.php.net/manual/en/function.is-sarcasm.php for more info.


*That's* gonna fill up their httpd logs. :-)
Jul 17 '05 #18
Well, the only situation I can think of is when you use PHP to parse .xml
files.

Otherwise, for maximum compatibility you would do

<?php

echo '<?xml version="1.0" encoding="utf-8"?>';
// PHP stuff

?>

instead of

<?xml version="1.0" encoding="utf-8"?>
<?php
// PHP stuff
?>

anyway, which, of course, removes the reason to turn short tags off.

Besides short tags I also use the alternative control structure syntax (<?
if($login): ?><p> ... </p><? endif; ?>), so I think the style police will
probably shoot me first ;-)

Uzytkownik "Jochen Buennagel" <za*********@buennagel.com> napisal w
wiadomosci news:bu*************@news.t-online.com...
John Dunlop wrote:
The Manual says that even "<?php" won't work on editors that don't
grok processing instructions, and, <sarcasm>lo and behold</sarcasm>,
FrontPage is given as an example. That doesn't stop them from
recommending using "<?php" though. I'm with them on that.


The Manual also says about short_open_tags: "If you want to use PHP in
combination with XML, you can disable this option."

There is no other reason given for turning them off. The fact that
short_open_tags=on is the default tells me that it is the preferred
setting for most applications, so I use it until someone (except the
style-police) complains.

Jochen

Jul 17 '05 #19
Chung Leong wrote:
Besides short tags I also use the alternative control structure syntax (<?
if($login): ?><p> ... </p><? endif; ?>), so I think the style police will
probably shoot me first ;-)


I do that too in templates, along with copious amounts of <?=$variable?>

Jochen

Jul 17 '05 #20
Regarding this well-known quote, often attributed to Chung Leong's famous
"Fri, 16 Jan 2004 12:46:53 -0500" speech:
Well, the only situation I can think of is when you use PHP to parse .xml
files.

Otherwise, for maximum compatibility you would do

<?php

echo '<?xml version="1.0" encoding="utf-8"?>';
// PHP stuff

?>

instead of

<?xml version="1.0" encoding="utf-8"?>
<?php
// PHP stuff
?>

anyway, which, of course, removes the reason to turn short tags off.

Besides short tags I also use the alternative control structure syntax (<?
if($login): ?><p> ... </p><? endif; ?>), so I think the style police will
probably shoot me first ;-)

Uzytkownik "Jochen Buennagel" <za*********@buennagel.com> napisal w
wiadomosci news:bu*************@news.t-online.com...
John Dunlop wrote:
The Manual says that even "<?php" won't work on editors that don't
grok processing instructions, and, <sarcasm>lo and behold</sarcasm>,
FrontPage is given as an example. That doesn't stop them from
recommending using "<?php" though. I'm with them on that.


The Manual also says about short_open_tags: "If you want to use PHP in
combination with XML, you can disable this option."

There is no other reason given for turning them off. The fact that
short_open_tags=on is the default tells me that it is the preferred
setting for most applications, so I use it until someone (except the
style-police) complains.

Jochen


Of course, if you're running straight, hardcoded XML, then the XML file
vomits whenever you feed it into anything that can't take PHP.
--
-- Rudy Fleminger
-- sp@mmers.and.evil.ones.will.bow-down-to.us
(put "Hey!" in the Subject line for priority processing!)
-- http://www.pixelsaredead.com
Jul 17 '05 #21

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Christian Schmidbauer | last post: by
2 posts views Thread by Donald Firesmith | last post: by
4 posts views Thread by higabe | last post: by
11 posts views Thread by Les Paul | last post: by
9 posts views Thread by Eric Lindsay | last post: by
8 posts views Thread by Efi Merdler | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.