RES: [PHP] Short tag: why is it bad practice?

2011-05-11 Thread Alejandro Michelin Salomon (Hotmail)
Andre :

As Joshua says, the only php tags that always is enabled is ?php ?, this
is the default php tag, and never can be disabled.

This ? ? is enabled if short_open_tag is on
And this % % is enabled if asp_tags is on

But the default is off for both.

Use this ?php ?, and forgive configuration options.

Alejandro M.S.

-Mensagem original-
De: Joshua Kehn [mailto:josh.k...@gmail.com] 
Enviada em: terça-feira, 10 de maio de 2011 12:19
Para: Andre Polykanine
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Short tag: why is it bad practice?

On May 10, 2011, at 11:11 AM, Andre Polykanine wrote:

 Hi everyone,
 Many  times  I heard that the following two peaces of code are written
 in a bad manner:
 1.
 ?
 echo Hello, world!;
 ?
 
 2.
 form action=script.php method=post
 pYour   e-mail:   input   type=text   id=uemail   name=uemail
 value=?=$f['Email']?/p
 ...
 /form
 
 As for now, I use both quite often. Why is this considered not kosher,
 I mean, good coding practice?
 Thanks!
 
 -- 
 With best regards from Ukraine,
 Andre
 Skype: Francophile
 Twitter: http://twitter.com/m_elensule
 Facebook: http://facebook.com/menelion


Because short tags aren't always enabled and can cause things to break when
deploying code to different environments. Best practice dictates that your
code should be as environmentally independent as possible.

It's another few characters, why neglect it?

Regards,

-Josh

Joshua Kehn | josh.k...@gmail.com
http://joshuakehn.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Short tag: why is it bad practice?

2011-05-11 Thread Daevid Vincent
 -Original Message-
 From: Joshua Kehn [mailto:josh.k...@gmail.com]
 Sent: Tuesday, May 10, 2011 8:19 AM
 To: Andre Polykanine
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Short tag: why is it bad practice?
 
 On May 10, 2011, at 11:11 AM, Andre Polykanine wrote:
 
  Hi everyone,
  Many  times  I heard that the following two peaces of code are written
  in a bad manner:
  1.
  ?
  echo Hello, world!;
  ?
 
  2.
  form action=script.php method=post
  pYour   e-mail:   input   type=text   id=uemail   name=uemail
  value=?=$f['Email']?/p
  ...
  /form
 
  As for now, I use both quite often. Why is this considered not kosher,
  I mean, good coding practice?
  Thanks!
 
  --
  With best regards from Ukraine,
  Andre
  Skype: Francophile
  Twitter: http://twitter.com/m_elensule
  Facebook: http://facebook.com/menelion
 
 
 Because short tags aren't always enabled and can cause things to break
when
 deploying code to different environments. Best practice dictates that your
 code should be as environmentally independent as possible.
 
 It's another few characters, why neglect it?

This is always a source of confusion.

http://www.bin-co.com/php/articles/using_php_short_tags.php

?= $foo ? is generally NOT what the short tags controversy are about.

It's the use of ? Some php here ?  vs. ?php some php here ?

While it is true that the 'short_open_tag' directive enables both (for some
stupid reason), the issue is that it's poor form to use JUST ? And not
?php just as it's a bad idea to use % % (asp tags).

Using ?= is perfectly fine and in my personal and professional opinion,
preferred to the uglier ?php echo $foo; ? way

This topic was very heated when the core PHP developers were going to remove
the ? Form all together in future PHP 6  versions and everyone got their
panties in a bunch because they assumed it meant the ?= form too (which it
did not).

http://php.net/manual/en/ini.core.php

http://www.php.net/~derick/meeting-notes.html#remove-support-for-and-script-
language-php-and-add-php-var





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Short tag: why is it bad practice?

2011-05-11 Thread Andre Polykanine
Hello,

 So, as I've understood, the only issue with ? // blah-blah ? is
the ?xml version 1.0? thing?
Thanks!



-- 
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

 Original message 
From: Daevid Vincent dae...@daevid.com
To: php-general@lists.php.net
Date created: , 9:55:23 PM
Subject: [PHP] Short tag: why is it bad practice?


   -Original Message-
 From: Joshua Kehn [mailto:josh.k...@gmail.com]
 Sent: Tuesday, May 10, 2011 8:19 AM
 To: Andre Polykanine
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Short tag: why is it bad practice?
 
 On May 10, 2011, at 11:11 AM, Andre Polykanine wrote:
 
  Hi everyone,
  Many  times  I heard that the following two peaces of code are written
  in a bad manner:
  1.
  ?
  echo Hello, world!;
  ?
 
  2.
  form action=script.php method=post
  pYour   e-mail:   input   type=text   id=uemail   name=uemail
  value=?=$f['Email']?/p
  ...
  /form
 
  As for now, I use both quite often. Why is this considered not kosher,
  I mean, good coding practice?
  Thanks!
 
  --
  With best regards from Ukraine,
  Andre
  Skype: Francophile
  Twitter: http://twitter.com/m_elensule
  Facebook: http://facebook.com/menelion
 
 
 Because short tags aren't always enabled and can cause things to break
when
 deploying code to different environments. Best practice dictates that your
 code should be as environmentally independent as possible.
 
 It's another few characters, why neglect it?

This is always a source of confusion.

http://www.bin-co.com/php/articles/using_php_short_tags.php

?= $foo ? is generally NOT what the short tags controversy are about.

It's the use of ? Some php here ?  vs. ?php some php here ?

While it is true that the 'short_open_tag' directive enables both (for some
stupid reason), the issue is that it's poor form to use JUST ? And not
?php just as it's a bad idea to use % % (asp tags).

Using ?= is perfectly fine and in my personal and professional opinion,
preferred to the uglier ?php echo $foo; ? way

This topic was very heated when the core PHP developers were going to remove
the ? Form all together in future PHP 6  versions and everyone got their
panties in a bunch because they assumed it meant the ?= form too (which it
did not).

http://php.net/manual/en/ini.core.php

http://www.php.net/~derick/meeting-notes.html#remove-support-for-and-script-
language-php-and-add-php-var





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Short tag: why is it bad practice?

2011-05-11 Thread David Harkness
On Wed, May 11, 2011 at 11:55 AM, Daevid Vincent dae...@daevid.com wrote:

 ?= $foo ? is generally NOT what the short tags controversy are about.


 It's the use of ? Some php here ?  vs. ?php some php here ?


This is the same thing my colleague told me when I first joined and began
learning PHP and is the reason we use ?= and ?php.

While it is true that the 'short_open_tag' directive enables both (for some
 stupid reason), the issue is that it's poor form to use JUST ? And not
 ?php just as it's a bad idea to use % % (asp tags).


This is what doesn't make sense to me. One camp says that short open tags
are bad because the option is not always enabled, but that would include ?=
as well. And if ? is only a problem when mixing PHP and XML--and you can
always echo the XML directive anyway--I don't see that ? is actually a
problem once you decide that ?= is okay (short_open_tags is enabled). The
file extension is .php so it should be safe to assume that ? means PHP
code follows just as ?= means a PHP expression follows.

There must be some other reason why ? is bad while ?= is okay. If not, no
big deal, and I'll probably keep using ?php anyway, but it seems odd that
there would be so much controversy over it.

This topic was very heated when the core PHP developers were going to remove
 the ? Form all together in future PHP 6  versions and everyone got their
 panties in a bunch because they assumed it meant the ?= form too (which it
 did not).


Out of curiosity, did the original proposal for PHP 6 remove the
short_open_tags setting (and thus ?= as well) or did it redefine ?= not to
be a short open tag?

David


[PHP] Short tag: why is it bad practice?

2011-05-10 Thread Andre Polykanine
Hi everyone,
Many  times  I heard that the following two peaces of code are written
in a bad manner:
1.
?
echo Hello, world!;
?

2.
form action=script.php method=post
pYour   e-mail:   input   type=text   id=uemail   name=uemail
value=?=$f['Email']?/p
...
/form

As for now, I use both quite often. Why is this considered not kosher,
I mean, good coding practice?
Thanks!

-- 
With best regards from Ukraine,
Andre
Skype: Francophile
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Short tag: why is it bad practice?

2011-05-10 Thread Joshua Kehn
On May 10, 2011, at 11:11 AM, Andre Polykanine wrote:

 Hi everyone,
 Many  times  I heard that the following two peaces of code are written
 in a bad manner:
 1.
 ?
 echo Hello, world!;
 ?
 
 2.
 form action=script.php method=post
 pYour   e-mail:   input   type=text   id=uemail   name=uemail
 value=?=$f['Email']?/p
 ...
 /form
 
 As for now, I use both quite often. Why is this considered not kosher,
 I mean, good coding practice?
 Thanks!
 
 -- 
 With best regards from Ukraine,
 Andre
 Skype: Francophile
 Twitter: http://twitter.com/m_elensule
 Facebook: http://facebook.com/menelion


Because short tags aren't always enabled and can cause things to break when 
deploying code to different environments. Best practice dictates that your code 
should be as environmentally independent as possible.

It's another few characters, why neglect it?

Regards,

-Josh

Joshua Kehn | josh.k...@gmail.com
http://joshuakehn.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php