Setting of <? and <?php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • wing

    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


  • Tim Van Wassenhove

    #2
    Re: Setting of &lt;? and &lt;?php

    On 2004-01-14, wing <wing@wing.co m> wrote:[color=blue]
    > 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??[/color]

    short_open_tag = on

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

    --

    Comment

    • wing

      #3
      Re: Setting of &lt;? and &lt;?php

      "Tim Van Wassenhove" <euki@pi.be> ¦b¶l¥ó
      news:bu2til$cpq l1$1@ID-188825.news.uni-berlin.de ¤¤¼¶¼g...[color=blue]
      > On 2004-01-14, wing <wing@wing.co m> wrote:[color=green]
      > > Hi,
      > >
      > > I'm now doing web programming using PHP. I need to use <?php instead of[/color][/color]
      <?[color=blue][color=green]
      > > for PHP scripts.
      > >
      > > How do I configure PHP so that it can recognize <? as well??[/color]
      >
      > short_open_tag = on
      >
      > But be aware, there are some issues you should be aware of when using
      > it.[/color]
      Thanks for your reply but can you please specify what needs to be aware of??

      Wing

      [color=blue]
      >
      > --
      > http://home.mysth.be/~timvw[/color]


      Comment

      • Rahul Anand

        #4
        Re: Setting of &lt;? and &lt;?php

        "wing" <wing@wing.co m> wrote in message news:<bu2pfr$gn k$1@news.ust.hk >...[color=blue]
        > 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[/color]

        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

        Comment

        • Agelmar

          #5
          Re: Setting of &lt;? and &lt;?php

          wing wrote:[color=blue]
          > "Tim Van Wassenhove" <euki@pi.be> ¦b¶l¥ó
          > news:bu2til$cpq l1$1@ID-188825.news.uni-berlin.de ¤¤¼¶¼g...[color=green]
          >> On 2004-01-14, wing <wing@wing.co m> wrote:[color=darkred]
          >>> 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??[/color]
          >>
          >> short_open_tag = on
          >>
          >> But be aware, there are some issues you should be aware of when using
          >> it.[/color]
          > Thanks for your reply but can you please specify what needs to be
          > aware of??
          >
          > Wing[/color]

          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.


          Comment

          • Jochen Buennagel

            #6
            Re: Setting of &lt;? and &lt;?php

            Agelmar wrote:
            [color=blue]
            > 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.[/color]

            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

            Comment

            • Agelmar

              #7
              Re: Setting of &lt;? and &lt;?php

              Jochen Buennagel wrote:[color=blue]
              > Agelmar wrote:
              >[color=green]
              >> 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.[/color]
              >
              > 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[/color]

              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.


              Comment

              • Chung Leong

                #8
                Re: Setting of &lt;? and &lt;?php

                Both <?php and <? are poor style. We should all use <script
                language="php"> </script> instead.

                Uzytkownik "Agelmar" <ifetteNOSPAM@c omcast.net> napisal w wiadomosci
                news:bu4kik$d8o b3$1@ID-30799.news.uni-berlin.de...[color=blue]
                > Jochen Buennagel wrote:[color=green]
                > > Agelmar wrote:
                > >[color=darkred]
                > >> 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.[/color]
                > >
                > > 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[/color]
                >
                > 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[/color]
                on[color=blue]
                > all platforms. <? will not. Thus, if you care about compatibility, it's a[/color]
                no[color=blue]
                > brainer.
                >
                >[/color]


                Comment

                • Agelmar

                  #9
                  Re: Setting of &lt;? and &lt;?php

                  Chung Leong wrote:[color=blue]
                  > Both <?php and <? are poor style. We should all use <script
                  > language="php"> </script> instead.[/color]

                  Hmm... actually, that's not a bad suggestion.


                  Comment

                  • Jochen Buennagel

                    #10
                    Re: Setting of &lt;? and &lt;?php

                    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).

                    Comment

                    • John Dunlop

                      #11
                      Re: Setting of &lt;? and &lt;?php

                      Chung Leong wrote upsidedown:
                      [color=blue]
                      > We should all use <script language="php"> </script> instead.[/color]

                      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

                      Comment

                      • Savut

                        #12
                        Re: Setting of &lt;? and &lt;?php

                        XML use <? also

                        Savut

                        "wing" <wing@wing.co m> wrote in message news:bu2pfr$gnk $1@news.ust.hk. ..[color=blue]
                        > 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
                        >
                        >[/color]


                        Comment

                        • Chung Leong

                          #13
                          Re: Setting of &lt;? and &lt;?php

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

                          Uzytkownik "John Dunlop" <john+usenet@jo hndunlop.info> napisal w wiadomosci
                          news:MPG.1a7091 53b419e1a09897e a@news.freeserv e.net...[color=blue]
                          > Chung Leong wrote upsidedown:
                          >[color=green]
                          > > We should all use <script language="php"> </script> instead.[/color]
                          >
                          > 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[/color]


                          Comment

                          • Jochen Buennagel

                            #14
                            Re: Setting of &lt;? and &lt;?php

                            Chung Leong wrote:[color=blue]
                            > See http://www.php.net/manual/en/function.is-sarcasm.php for more info.[/color]

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

                            Jochen

                            Comment

                            • John Dunlop

                              #15
                              Re: Setting of &lt;? and &lt;?php

                              Chung Leong wrote upsidedown:
                              [color=blue]
                              > Uzytkownik "John Dunlop" <john+usenet@jo hndunlop.info> napisal w wiadomosci
                              > news:MPG.1a7091 53b419e1a09897e a@news.freeserv e.net...[color=green]
                              > > Chung Leong wrote upsidedown:
                              > >[color=darkred]
                              > > > We should all use <script language="php"> </script> instead.[/color]
                              > >
                              > > 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?[/color]
                              >
                              > See http://www.php.net/manual/en/function.is-sarcasm.php for more info.[/color]

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




                              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

                              Comment

                              Working...