php syntax question

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

    php syntax question

    Hello. Rank php newbie, here. I just setup my Slack 12 httpd to run php
    based on advice I found in Linuxquestions. I finally got it working, but
    the prob was not the config, which I had no prob with, but the syntax of a
    simple php file. The test.php file given was:

    <? phpinfo(); ?>

    .....which didn't work. But, fooling around with some other expamples, I
    noticed <?php ? syntax instead of just <? ?>. I added the "php":

    <?php phpinfo(); ?>

    .....and the test file worked just fine. So, what's the deal? Is there a
    configuration I can make or does php5 (apache2) always require the "php" in
    the tag?

    thank you,
    nb
  • Rik Wasmus

    #2
    Re: php syntax question

    On Sun, 18 May 2008 21:20:41 +0200, notbob <notbob@nothome .comwrote:
    Hello. Rank php newbie, here. I just setup my Slack 12 httpd to run php
    based on advice I found in Linuxquestions. I finally got it working, but
    the prob was not the config, which I had no prob with, but the syntax of
    a
    simple php file. The test.php file given was:
    >
    <? phpinfo(); ?>
    >
    ....which didn't work. But, fooling around with some other expamples, I
    noticed <?php ? syntax instead of just <? ?>. I added the "php":
    >
    <?php phpinfo(); ?>
    >
    ....and the test file worked just fine. So, what's the deal? Is there a
    configuration I can make or does php5 (apache2) always require the "php"
    in
    the tag?
    Search the manual for short_open_tags . And rather then enabling it (which
    could cause trouble with XML, and make your script not work on a server
    with it disabled), just change all your php tags to proper <?php.
    --
    Rik Wasmus
    ....spamrun finished

    Comment

    • Peter H. Coffin

      #3
      Re: php syntax question

      On Sun, 18 May 2008 19:20:41 GMT, notbob wrote:
      Hello. Rank php newbie, here. I just setup my Slack 12 httpd to run php
      based on advice I found in Linuxquestions. I finally got it working, but
      the prob was not the config, which I had no prob with, but the syntax of a
      simple php file. The test.php file given was:
      >
      ><? phpinfo(); ?>
      >
      ....which didn't work. But, fooling around with some other expamples, I
      noticed <?php ? syntax instead of just <? ?>. I added the "php":
      >
      ><?php phpinfo(); ?>
      >
      ....and the test file worked just fine. So, what's the deal? Is there a
      configuration I can make or does php5 (apache2) always require the "php" in
      the tag?
      It's the configuration variable short_open_tag in the php.ini file.
      Whether you want to turn it on or not is up to you but be aware that if
      you're wirting things for placement in an environment where you may not
      be in control of the php.ini (such as a hosted space), you may want to
      discipline yourself to use the full open tag always.

      --
      41. Once my power is secure, I will destroy all those pesky time-travel
      devices.
      --Peter Anspach's list of things to do as an Evil Overlord

      Comment

      • larry@portcommodore.com

        #4
        Re: php syntax question

        On May 18, 12:20 pm, notbob <not...@nothome .comwrote:
        ....and the test file worked just fine. So, what's the deal? Is there a
        configuration I can make or does php5 (apache2) always require the "php" in
        the tag?
        >
        thank you,
        nb
        <? ?can be just about any scripting language on a webserver (and if
        it is IIS it could very well be ASP).

        <?php ?can only be php

        Use the longer tags and life will be good, and you will not have to
        fix it later (IIRC PHP 6 will require long tags).

        Comment

        • notbob

          #5
          Re: php syntax question

          On 2008-05-18, Peter H. Coffin <hellsop@ninehe lls.comwrote:
          discipline yourself to use the full open tag always.
          Thank you, Rik and Peter. I suspected something like that and so will leave
          the config option be and use proper php syntax. I've been doing likewise
          with html (no <p tags) and have noticed less problems. I'm finding it's
          better to take the time up front than spend more time debugging.

          nb

          Comment

          • Peter H. Coffin

            #6
            Re: php syntax question

            On Sun, 18 May 2008 13:00:14 -0700 (PDT), larry@portcommo dore.com wrote:
            On May 18, 12:20 pm, notbob <not...@nothome .comwrote:
            >
            >....and the test file worked just fine. So, what's the deal? Is there a
            >configuratio n I can make or does php5 (apache2) always require the "php" in
            >the tag?
            >>
            >thank you,
            >nb
            >
            ><? ?can be just about any scripting language on a webserver (and if
            it is IIS it could very well be ASP).
            >
            ><?php ?can only be php
            Indeed, and there's little to nothing that I can think of that would
            prevent a (im)properly configured webserver from parsing the same page
            for multiple different script languages. It would be ... interesting to
            write for if you knew which would be processed first, and a nightmare if
            you didn't.

            --
            When you have a thermic lance, everything looks like hours of fun.
            -- Christian Wagner in a.s.r

            Comment

            Working...