Why does include file text need to be bracketed by <?php> ... <?>

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

    Why does include file text need to be bracketed by <?php> ... <?>

    Since the include function is called from within a PHP script, why
    does the included file have to identify itself as a PHP again by
    enclosing its code in <?php... <?>

    One would assume that the PHP interpreter works like any other, that
    is, it first expands all the include files, and then parses the
    resulting text. Can anyone help with an explanation?

    Thanks,
    M. McDonnell

  • Jon Slaughter

    #2
    Re: Why does include file text need to be bracketed by &lt;?php&gt; ... &lt;?&gt;


    "Michael" <MichaelDMcDonn ell@yahoo.comwr ote in message
    news:1180368213 .786423.310320@ z28g2000prd.goo glegroups.com.. .
    Since the include function is called from within a PHP script, why
    does the included file have to identify itself as a PHP again by
    enclosing its code in <?php... <?>
    >
    One would assume that the PHP interpreter works like any other, that
    is, it first expands all the include files, and then parses the
    resulting text. Can anyone help with an explanation?
    >
    Because a php can contain other text such as html... the parser is only
    signaled to work on the block that is inside a the php tag...

    you ever wonder why <? php ?looks like an html tag? cause it is!


    Comment

    • Darko

      #3
      Re: Why does include file text need to be bracketed by &lt;?php&gt; ... &lt;?&gt;

      On May 28, 6:03 pm, Michael <MichaelDMcDonn ...@yahoo.comwr ote:
      Since the include function is called from within a PHP script, why
      does the included file have to identify itself as a PHP again by
      enclosing its code in <?php... <?>
      >
      One would assume that the PHP interpreter works like any other, that
      is, it first expands all the include files, and then parses the
      resulting text. Can anyone help with an explanation?
      >
      Thanks,
      M. McDonnell
      It's not supposed to be bracketed by <?phpand <?>, but by <?php and ?
      >. That's not necessary, though. You have to put those symbols into
      your require-d file if you want it to be understood like php code, but
      if you don't, it will be understood as raw output. Just like any other
      php file:
      <?php
      if ( $x ) {
      ?>
      some output here
      some output here
      some output here
      <?php
      } else {
      ?>
      some other output here
      some other output here
      some other output here
      <?php

      Comment

      • Darko

        #4
        Re: Why does include file text need to be bracketed by &lt;?php&gt; ... &lt;?&gt;

        On May 28, 6:09 pm, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:
        "Michael" <MichaelDMcDonn ...@yahoo.comwr ote in message
        >
        news:1180368213 .786423.310320@ z28g2000prd.goo glegroups.com.. .
        >
        Since the include function is called from within a PHP script, why
        does the included file have to identify itself as a PHP again by
        enclosing its code in <?php... <?>
        >
        One would assume that the PHP interpreter works like any other, that
        is, it first expands all the include files, and then parses the
        resulting text. Can anyone help with an explanation?
        It's not supposed to be bracketed by <?phpand <?>, but by <?php
        and ?
        >. That's not necessary, though. You have to put those symbols into
        your require-d file if you want it to be understood like php code, but
        if you don't, it will be understood as raw output. Just like any other
        php file:
        <?php
        if ( $x ) {
        ?>
        some output here
        some output here
        some output here
        <?php
        } else {
        ?>
        some other output here
        some other output here
        some other output here
        <?php
        }
        ?>

        As for the require-d file, the same counts - if you didn't put <?php
        and ?surrounding the contents of the file, they would be understood
        as ordinary output, not php code (which, of course, can be exactly
        what we wanted).
        >
        Because a php can contain other text such as html... the parser is only
        signaled to work on the block that is inside a the php tag...
        >
        you ever wonder why <? php ?looks like an html tag? cause it is!
        I wouldn't go that far to say <?php and ?are html tags, although
        they do resemble them having lt and gt chars. Actually, the <? and ?>
        are part of xml processing instruction declaration syntax, so when we
        say "<?php" we say "give the following contents to php", and when we
        say "?>", we actually say "those contents end here". So, php code is
        actually organized as xml document, and html out of <?php ?>
        instructions perfectly fits in that concept, being itself a subset of
        xml, although older than xml.

        Comment

        • Michael

          #5
          Re: Why does include file text need to be bracketed by &lt;?php&gt; ... &lt;?&gt;

          On May 28, 9:24 am, Darko <darko.maksimo. ..@gmail.comwro te:
          On May 28, 6:09 pm, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:"Michael" <MichaelDMcDonn ...@yahoo.comwr ote in message
          >
          news:1180368213 .786423.310320@ z28g2000prd.goo glegroups.com.. .
          >
          Since the include function is called from within a PHP script, why
          does the included file have to identify itself as a PHP again by
          enclosing its code in <?php... <?>
          >
          One would assume that the PHP interpreter works like any other, that
          is, it first expands all the include files, and then parses the
          resulting text. Can anyone help with an explanation?
          >
          It's not supposed to be bracketed by <?phpand <?>, but by <?php
          and ?
          >
          . That's not necessary, though. You have to put those symbols into
          >
          your require-d file if you want it to be understood like php code, but
          if you don't, it will be understood as raw output. Just like any other
          php file:
          <?php
          if ( $x ) {
          ?>
          some output here
          some output here
          some output here
          <?php
          } else {
          ?>
          some other output here
          some other output here
          some other output here
          <?php
          }
          ?>
          >
          As for the require-d file, the same counts - if you didn't put <?php
          and ?surrounding the contents of the file, they would be understood
          as ordinary output, not php code (which, of course, can be exactly
          what we wanted).
          >
          >
          >
          Because a php can contain other text such as html... the parser is only
          signaled to work on the block that is inside a the php tag...
          >
          you ever wonder why <? php ?looks like an html tag? cause it is!
          >
          I wouldn't go that far to say <?php and ?are html tags, although
          they do resemble them having lt and gt chars. Actually, the <? and ?>
          are part of xml processing instruction declaration syntax, so when we
          say "<?php" we say "give the following contents to php", and when we
          say "?>", we actually say "those contents end here". So, php code is
          actually organized as xml document, and html out of <?php ?>
          instructions perfectly fits in that concept, being itself a subset of
          xml, although older than xml.
          =============== ======
          I guess I'm still missing the point. Once the browser interpreter sees
          the <?php, it assumes that all text to follow is php code until the
          terminating token ?is seen. Now if the include function is called
          within the <?php ... ?>, the interpreter still assumes that any text
          it sees is PHP. So again, I don't understand why the include text
          needs to bracket its code in <?php ...?>. What am I missing here?
          Thanks, MDM.

          Comment

          • Jon Slaughter

            #6
            Re: Why does include file text need to be bracketed by &lt;?php&gt; ... &lt;?&gt;


            "Michael" <MichaelDMcDonn ell@yahoo.comwr ote in message
            news:1180370371 .580860.72150@x 35g2000prf.goog legroups.com...
            On May 28, 9:24 am, Darko <darko.maksimo. ..@gmail.comwro te:
            >On May 28, 6:09 pm, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:>
            >"Michael" <MichaelDMcDonn ...@yahoo.comwr ote in message
            >>
            >news:118036821 3.786423.310320 @z28g2000prd.go oglegroups.com. ..
            >>
            Since the include function is called from within a PHP script, why
            does the included file have to identify itself as a PHP again by
            enclosing its code in <?php... <?>
            >>
            One would assume that the PHP interpreter works like any other, that
            is, it first expands all the include files, and then parses the
            resulting text. Can anyone help with an explanation?
            >>
            >It's not supposed to be bracketed by <?phpand <?>, but by <?php
            >and ?
            >>
            >. That's not necessary, though. You have to put those symbols into
            >>
            >your require-d file if you want it to be understood like php code, but
            >if you don't, it will be understood as raw output. Just like any other
            >php file:
            ><?php
            > if ( $x ) {
            >?>
            >some output here
            >some output here
            >some output here
            ><?php
            > } else {
            >?>
            >some other output here
            >some other output here
            >some other output here
            ><?php
            > }
            >?>
            >>
            >As for the require-d file, the same counts - if you didn't put <?php
            >and ?surrounding the contents of the file, they would be understood
            >as ordinary output, not php code (which, of course, can be exactly
            >what we wanted).
            >>
            >>
            >>
            Because a php can contain other text such as html... the parser is only
            signaled to work on the block that is inside a the php tag...
            >>
            you ever wonder why <? php ?looks like an html tag? cause it is!
            >>
            >I wouldn't go that far to say <?php and ?are html tags, although
            >they do resemble them having lt and gt chars. Actually, the <? and ?>
            >are part of xml processing instruction declaration syntax, so when we
            >say "<?php" we say "give the following contents to php", and when we
            >say "?>", we actually say "those contents end here". So, php code is
            >actually organized as xml document, and html out of <?php ?>
            >instructions perfectly fits in that concept, being itself a subset of
            >xml, although older than xml.
            >
            =============== ======
            I guess I'm still missing the point. Once the browser interpreter sees
            the <?php, it assumes that all text to follow is php code until the
            terminating token ?is seen. Now if the include function is called
            within the <?php ... ?>, the interpreter still assumes that any text
            it sees is PHP. So again, I don't understand why the include text
            needs to bracket its code in <?php ...?>. What am I missing here?
            Thanks, MDM.
            >
            Thats your problem... php has nothing to do with the browser. Its a server
            side scripting language and independent of the client.


            Comment

            • Michael

              #7
              Re: Why does include file text need to be bracketed by &lt;?php&gt; ... &lt;?&gt;

              On May 28, 10:05 am, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.com>
              wrote:
              "Michael" <MichaelDMcDonn ...@yahoo.comwr ote in message
              >
              news:1180370371 .580860.72150@x 35g2000prf.goog legroups.com...
              >
              >
              >
              >
              >
              On May 28, 9:24 am, Darko <darko.maksimo. ..@gmail.comwro te:
              On May 28, 6:09 pm, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:>
              "Michael" <MichaelDMcDonn ...@yahoo.comwr ote in message
              >
              news:1180368213 .786423.310320@ z28g2000prd.goo glegroups.com.. .
              >
              Since the include function is called from within a PHP script, why
              does the included file have to identify itself as a PHP again by
              enclosing its code in <?php... <?>
              >
              One would assume that the PHP interpreter works like any other, that
              is, it first expands all the include files, and then parses the
              resulting text. Can anyone help with an explanation?
              >
              It's not supposed to be bracketed by <?phpand <?>, but by <?php
              and ?
              >
              . That's not necessary, though. You have to put those symbols into
              >
              your require-d file if you want it to be understood like php code, but
              if you don't, it will be understood as raw output. Just like any other
              php file:
              <?php
              if ( $x ) {
              ?>
              some output here
              some output here
              some output here
              <?php
              } else {
              ?>
              some other output here
              some other output here
              some other output here
              <?php
              }
              ?>
              >
              As for the require-d file, the same counts - if you didn't put <?php
              and ?surrounding the contents of the file, they would be understood
              as ordinary output, not php code (which, of course, can be exactly
              what we wanted).
              >
              Because a php can contain other text such as html... the parser is only
              signaled to work on the block that is inside a the php tag...
              >
              you ever wonder why <? php ?looks like an html tag? cause it is!
              >
              I wouldn't go that far to say <?php and ?are html tags, although
              they do resemble them having lt and gt chars. Actually, the <? and ?>
              are part of xml processing instruction declaration syntax, so when we
              say "<?php" we say "give the following contents to php", and when we
              say "?>", we actually say "those contents end here". So, php code is
              actually organized as xml document, and html out of <?php ?>
              instructions perfectly fits in that concept, being itself a subset of
              xml, although older than xml.
              >
              =============== ======
              I guess I'm still missing the point. Once the browser interpreter sees
              the <?php, it assumes that all text to follow is php code until the
              terminating token ?is seen. Now if the include function is called
              within the <?php ... ?>, the interpreter still assumes that any text
              it sees is PHP. So again, I don't understand why the include text
              needs to bracket its code in <?php ...?>. What am I missing here?
              Thanks, MDM.
              >
              Thats your problem... php has nothing to do with the browser. Its a server
              side scripting language and independent of the client.- Hide quoted text -
              >
              - Show quoted text -
              =============== ==============
              Yes, the text "browser interpreter" should replaced by "interprete r".
              In any case, it would seem that the question is still valid. Any
              comments would be appreciated.
              MDM

              Comment

              • farrishj@gmail.com

                #8
                Re: Why does include file text need to be bracketed by &lt;?php&gt; ... &lt;?&gt;

                On May 28, 12:45 pm, Michael <MichaelDMcDonn ...@yahoo.comwr ote:
                =============== ==============
                Yes, the text "browser interpreter" should replaced by "interprete r".
                In any case, it would seem that the question is still valid. Any
                comments would be appreciated.
                MDM
                I think I see what you're getting at. If you include a file, you still
                need parser instructions for the contents of the included file, since
                the include file can have processor directives just the same as the
                including script does. To wit:

                <code file="index.php ">
                <?php
                include 'html-header.inc.php' ;
                include 'main.inc.php';
                include 'html-footer.inc.php' ;
                ?>
                </code>

                <code file="html-header.inc.php" >
                <html>
                <head><title><? php echo COMPANY_NAME; ?></title></head>
                <body>
                <?php include 'company-header.inc.php' ; ?>
                </code>

                <code file="main.inc. php">
                <?php
                $inc = '/LIB/section-'.$_GET['section'].'inc.php';
                include $inc;
                ?>
                </code>

                <code file="html-footer.inc.php" >
                <?php include 'company-footer.inc.php' ; ?>
                </body>
                </html>
                </code>

                So as you see, you have to have <?php ?tags on included content, as
                that included content may still contain a mix of processor directives
                and hard-coded data (like html).

                Incidentally, you really only need <?php if a page is all php; the
                parser will close the file and auto-insert a ?to finish. However, I
                generally this to be bad practice and always insert it anyways.

                Comment

                • gosha bine

                  #9
                  Re: Why does include file text need to be bracketed by &lt;?php&gt; ...&lt;?&gt;

                  Michael wrote:
                  Since the include function is called from within a PHP script, why
                  does the included file have to identify itself as a PHP again by
                  enclosing its code in <?php... <?>
                  >
                  One would assume that the PHP interpreter works like any other, that
                  is, it first expands all the include files, and then parses the
                  resulting text. Can anyone help with an explanation?
                  Unlike, say, C preprocessor instructions or java's imports, php
                  include() is executed when your script runs, not when it compiles. When
                  interpreter encounters an "include", it reads the given file and
                  evaluates its context as php code. "include" is just a confusing name,
                  "included" files are actually not "embedded" in main file.


                  --
                  gosha bine

                  extended php parser ~ http://code.google.com/p/pihipi
                  blok ~ http://www.tagarga.com/blok

                  Comment

                  • Michael

                    #10
                    Re: Why does include file text need to be bracketed by &lt;?php&gt; ... &lt;?&gt;

                    On May 28, 10:05 am, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.com>
                    wrote:
                    "Michael" <MichaelDMcDonn ...@yahoo.comwr ote in message
                    >
                    news:1180370371 .580860.72150@x 35g2000prf.goog legroups.com...
                    >
                    >
                    >
                    >
                    >
                    On May 28, 9:24 am, Darko <darko.maksimo. ..@gmail.comwro te:
                    On May 28, 6:09 pm, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:>
                    "Michael" <MichaelDMcDonn ...@yahoo.comwr ote in message
                    >
                    news:1180368213 .786423.310320@ z28g2000prd.goo glegroups.com.. .
                    >
                    Since the include function is called from within a PHP script, why
                    does the included file have to identify itself as a PHP again by
                    enclosing its code in <?php... <?>
                    >
                    One would assume that the PHP interpreter works like any other, that
                    is, it first expands all the include files, and then parses the
                    resulting text. Can anyone help with an explanation?
                    >
                    It's not supposed to be bracketed by <?phpand <?>, but by <?php
                    and ?
                    >
                    . That's not necessary, though. You have to put those symbols into
                    >
                    your require-d file if you want it to be understood like php code, but
                    if you don't, it will be understood as raw output. Just like any other
                    php file:
                    <?php
                    if ( $x ) {
                    ?>
                    some output here
                    some output here
                    some output here
                    <?php
                    } else {
                    ?>
                    some other output here
                    some other output here
                    some other output here
                    <?php
                    }
                    ?>
                    >
                    As for the require-d file, the same counts - if you didn't put <?php
                    and ?surrounding the contents of the file, they would be understood
                    as ordinary output, not php code (which, of course, can be exactly
                    what we wanted).
                    >
                    Because a php can contain other text such as html... the parser is only
                    signaled to work on the block that is inside a the php tag...
                    >
                    you ever wonder why <? php ?looks like an html tag? cause it is!
                    >
                    I wouldn't go that far to say <?php and ?are html tags, although
                    they do resemble them having lt and gt chars. Actually, the <? and ?>
                    are part of xml processing instruction declaration syntax, so when we
                    say "<?php" we say "give the following contents to php", and when we
                    say "?>", we actually say "those contents end here". So, php code is
                    actually organized as xml document, and html out of <?php ?>
                    instructions perfectly fits in that concept, being itself a subset of
                    xml, although older than xml.
                    >
                    =============== ======
                    I guess I'm still missing the point. Once the browser interpreter sees
                    the <?php, it assumes that all text to follow is php code until the
                    terminating token ?is seen. Now if the include function is called
                    within the <?php ... ?>, the interpreter still assumes that any text
                    it sees is PHP. So again, I don't understand why the include text
                    needs to bracket its code in <?php ...?>. What am I missing here?
                    Thanks, MDM.
                    >
                    Thats your problem... php has nothing to do with the browser. Its a server
                    side scripting language and independent of the client.- Hide quoted text -
                    >
                    - Show quoted text -
                    =============== ==============
                    Yes, the text "browser interpreter" should replaced by "interprete r".
                    In any case, it would seem that the question is still valid. Any
                    comments would be appreciated.
                    MDM

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: Why does include file text need to be bracketed by &lt;?php&gt; ...&lt;?&gt;

                      Michael wrote:
                      On May 28, 10:05 am, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.com>
                      wrote:
                      >"Michael" <MichaelDMcDonn ...@yahoo.comwr ote in message
                      >>
                      >news:118037037 1.580860.72150@ x35g2000prf.goo glegroups.com.. .
                      >>
                      >>
                      >>
                      >>
                      >>
                      >>On May 28, 9:24 am, Darko <darko.maksimo. ..@gmail.comwro te:
                      >>>On May 28, 6:09 pm, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:>
                      >>>"Michael" <MichaelDMcDonn ...@yahoo.comwr ote in message
                      >>>>news:118036 8213.786423.310 320@z28g2000prd .googlegroups.c om...
                      >>>>>Since the include function is called from within a PHP script, why
                      >>>>>does the included file have to identify itself as a PHP again by
                      >>>>>enclosin g its code in <?php... <?>
                      >>>>>One would assume that the PHP interpreter works like any other, that
                      >>>>>is, it first expands all the include files, and then parses the
                      >>>>>resultin g text. Can anyone help with an explanation?
                      >>>It's not supposed to be bracketed by <?phpand <?>, but by <?php
                      >>>and ?
                      >>>>. That's not necessary, though. You have to put those symbols into
                      >>>your require-d file if you want it to be understood like php code, but
                      >>>if you don't, it will be understood as raw output. Just like any other
                      >>>php file:
                      >>><?php
                      >>> if ( $x ) {
                      >>>?>
                      >>>some output here
                      >>>some output here
                      >>>some output here
                      >>><?php
                      >>> } else {
                      >>>?>
                      >>>some other output here
                      >>>some other output here
                      >>>some other output here
                      >>><?php
                      >>> }
                      >>>?>
                      >>>As for the require-d file, the same counts - if you didn't put <?php
                      >>>and ?surrounding the contents of the file, they would be understood
                      >>>as ordinary output, not php code (which, of course, can be exactly
                      >>>what we wanted).
                      >>>>Because a php can contain other text such as html... the parser is only
                      >>>>signaled to work on the block that is inside a the php tag...
                      >>>>you ever wonder why <? php ?looks like an html tag? cause it is!
                      >>>I wouldn't go that far to say <?php and ?are html tags, although
                      >>>they do resemble them having lt and gt chars. Actually, the <? and ?>
                      >>>are part of xml processing instruction declaration syntax, so when we
                      >>>say "<?php" we say "give the following contents to php", and when we
                      >>>say "?>", we actually say "those contents end here". So, php code is
                      >>>actually organized as xml document, and html out of <?php ?>
                      >>>instructio ns perfectly fits in that concept, being itself a subset of
                      >>>xml, although older than xml.
                      >>============= ========
                      >>I guess I'm still missing the point. Once the browser interpreter sees
                      >>the <?php, it assumes that all text to follow is php code until the
                      >>terminating token ?is seen. Now if the include function is called
                      >>within the <?php ... ?>, the interpreter still assumes that any text
                      >>it sees is PHP. So again, I don't understand why the include text
                      >>needs to bracket its code in <?php ...?>. What am I missing here?
                      >>Thanks, MDM.
                      >Thats your problem... php has nothing to do with the browser. Its a server
                      >side scripting language and independent of the client.- Hide quoted text -
                      >>
                      >- Show quoted text -
                      =============== ==============
                      Yes, the text "browser interpreter" should replaced by "interprete r".
                      In any case, it would seem that the question is still valid. Any
                      comments would be appreciated.
                      MDM
                      >
                      Michel,

                      Because the included file may not necessarily contain PHP code. It can
                      contain html, for instance, with php code intermixed - just like any php
                      file. Or it may contain no php code at all.

                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • Michael

                        #12
                        Re: Why does include file text need to be bracketed by &lt;?php&gt; ... &lt;?&gt;

                        On May 28, 11:46 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
                        Michael wrote:
                        On May 28, 10:05 am, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.com>
                        wrote:
                        "Michael" <MichaelDMcDonn ...@yahoo.comwr ote in message
                        >
                        >news:118037037 1.580860.72150@ x35g2000prf.goo glegroups.com.. .
                        >
                        >On May 28, 9:24 am, Darko <darko.maksimo. ..@gmail.comwro te:
                        >>On May 28, 6:09 pm, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:>
                        >>"Michael" <MichaelDMcDonn ...@yahoo.comwr ote in message
                        >>>>news:118036 8213.786423.310 320@z28g2000prd .googlegroups.c om...
                        >>>>Since the include function is called from within a PHP script, why
                        >>>>does the included file have to identify itself as a PHP again by
                        >>>>enclosing its code in <?php... <?>
                        >>>>One would assume that the PHP interpreter works like any other, that
                        >>>>is, it first expands all the include files, and then parses the
                        >>>>resulting text. Can anyone help with an explanation?
                        >>It's not supposed to be bracketed by <?phpand <?>, but by <?php
                        >>and ?
                        >>>. That's not necessary, though. You have to put those symbols into
                        >>your require-d file if you want it to be understood like php code, but
                        >>if you don't, it will be understood as raw output. Just like any other
                        >>php file:
                        >><?php
                        >> if ( $x ) {
                        >>?>
                        >>some output here
                        >>some output here
                        >>some output here
                        >><?php
                        >> } else {
                        >>?>
                        >>some other output here
                        >>some other output here
                        >>some other output here
                        >><?php
                        >> }
                        >>?>
                        >>As for the require-d file, the same counts - if you didn't put <?php
                        >>and ?surrounding the contents of the file, they would be understood
                        >>as ordinary output, not php code (which, of course, can be exactly
                        >>what we wanted).
                        >>>Because a php can contain other text such as html... the parser is only
                        >>>signaled to work on the block that is inside a the php tag...
                        >>>you ever wonder why <? php ?looks like an html tag? cause it is!
                        >>I wouldn't go that far to say <?php and ?are html tags, although
                        >>they do resemble them having lt and gt chars. Actually, the <? and ?>
                        >>are part of xml processing instruction declaration syntax, so when we
                        >>say "<?php" we say "give the following contents to php", and when we
                        >>say "?>", we actually say "those contents end here". So, php code is
                        >>actually organized as xml document, and html out of <?php ?>
                        >>instruction s perfectly fits in that concept, being itself a subset of
                        >>xml, although older than xml.
                        >============== =======
                        >I guess I'm still missing the point. Once the browser interpreter sees
                        >the <?php, it assumes that all text to follow is php code until the
                        >terminating token ?is seen. Now if the include function is called
                        >within the <?php ... ?>, the interpreter still assumes that any text
                        >it sees is PHP. So again, I don't understand why the include text
                        >needs to bracket its code in <?php ...?>. What am I missing here?
                        >Thanks, MDM.
                        Thats your problem... php has nothing to do with the browser. Its a server
                        side scripting language and independent of the client.- Hide quoted text -
                        >
                        - Show quoted text -
                        =============== ==============
                        Yes, the text "browser interpreter" should replaced by "interprete r".
                        In any case, it would seem that the question is still valid. Any
                        comments would be appreciated.
                        MDM
                        >
                        Michel,
                        >
                        Because the included file may not necessarily contain PHP code. It can
                        contain html, for instance, with php code intermixed - just like any php
                        file. Or it may contain no php code at all.
                        >
                        --
                        =============== ===
                        Remove the "x" from my email address
                        Jerry Stuckle
                        JDS Computer Training Corp.
                        jstuck...@attgl obal.net
                        =============== ===- Hide quoted text -
                        >
                        - Show quoted text -
                        =============== =======
                        Thank you all for your very helpful answers to my question.

                        Comment

                        • Geoff Berrow

                          #13
                          Re: Why does include file text need to be bracketed by &lt;?php&gt; ... &lt;?&gt;

                          Message-ID: <1180370371.580 860.72150@x35g2 000prf.googlegr oups.comfrom
                          Michael contained the following:
                          >I guess I'm still missing the point. Once the browser interpreter sees
                          >the <?php, it assumes that all text to follow is php code until the
                          >terminating token ?is seen. Now if the include function is called
                          >within the <?php ... ?>, the interpreter still assumes that any text
                          >it sees is PHP. So again, I don't understand why the include text
                          >needs to bracket its code in <?php ...?>. What am I missing here?
                          Ummm...reading the manual?



                          "When a file is included, parsing drops out of PHP mode and into HTML
                          mode at the beginning of the target file, and resumes again at the end.
                          For this reason, any code inside the target file which should be
                          executed as PHP code must be enclosed within valid PHP start and end
                          tags."

                          --
                          Geoff Berrow (put thecat out to email)
                          It's only Usenet, no one dies.
                          My opinions, not the committee's, mine.
                          Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                          Comment

                          • jussist@gmail.com

                            #14
                            Re: Why does include file text need to be bracketed by &lt;?php&gt; ... &lt;?&gt;

                            Ummm...reading the manual?
                            >

                            >
                            "When a file is included, parsing drops out of PHP mode and into HTML
                            mode at the beginning of the target file, and resumes again at the end.
                            For this reason, any code inside the target file which should be
                            executed as PHP code must be enclosed within valid PHP start and end
                            tags."
                            Interesting topic this has been, and at last there is the correct
                            answer. I can easily imagine a situation where and included file,
                            whether being html, plain text or php, would be sometimes run
                            separately, sometimes as included file. If including would require
                            the ?-tags or <?php -tags, the whole include -functionality would
                            become unusable. This kind of behavior could of course be done with a
                            parameter that would determine whether those tags would be needed or
                            not, but that's another story then.

                            On the other issue about <?php -tags. In no way <?php is an html -tag.
                            It is not one, period. <% is not html tag, <cfoutput is not an html -
                            tag, <?= is not an html tag. Neither is any other markup that is used
                            in some own server side software to identify interpreted parts of the
                            code. Html -tags are listed in: http://www.w3.org/TR/html401/index/elements.html
                            ..

                            --
                            Jussi T
                            Domain view.fi is for sale. Check the price from our site! Catcha.fi is a service where you can buy .fi domains.

                            This domain name has been registered with Gandi.net. It is currently parked by the owner.



                            Comment

                            • Geoff Berrow

                              #15
                              Re: Why does include file text need to be bracketed by &lt;?php&gt; ... &lt;?&gt;

                              Message-ID: <1180424267.967 370.269520@k79g 2000hse.googleg roups.comfrom
                              jussist@gmail.c om contained the following:
                              >On the other issue about <?php -tags. In no way <?php is an html -tag.
                              >It is not one, period.
                              Indeed. In normal circumstances the browser never sees it.
                              --
                              Geoff Berrow (put thecat out to email)
                              It's only Usenet, no one dies.
                              My opinions, not the committee's, mine.
                              Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                              Comment

                              Working...