.php5 versus .php

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

    #1

    .php5 versus .php

    I am working in two environments neither configuration of
    which I can change; one's my Web host the other a client.

    My Web host requires the use of the ".php5" extension
    to use PHP v5.1.4; where ".php" is used for PHP v4.3.11.
    My client supports PHP v5.2.0 with the ".php" extension.

    Is there a way to reliably determine if the ".php5" extension
    must be used on a server? Perhaps via a "phpinfo()" value?

    I have a page that uses the v5 function "file_put_conte nts()".
    (I like it's LOCK_EX feature.)

    Thanks in advance.


  • McKirahan

    #2
    Re: .php5 versus .php

    "McKirahan" <News@McKirahan .comwrote in message
    news:dO6dnRHVOf LPGknYnZ2dnUVZ_ uy3nZ2d@comcast .com...
    I am working in two environments neither configuration of
    which I can change; one's my Web host the other a client.
    >
    My Web host requires the use of the ".php5" extension
    to use PHP v5.1.4; where ".php" is used for PHP v4.3.11.
    My client supports PHP v5.2.0 with the ".php" extension.
    >
    Is there a way to reliably determine if the ".php5" extension
    must be used on a server? Perhaps via a "phpinfo()" value?
    >
    I have a page that uses the v5 function "file_put_conte nts()".
    (I like it's LOCK_EX feature.)
    >
    Thanks in advance.

    I tried this (to not write to the file in the function isn't supported):

    try {
    file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
    } catch (Exception $e) {
    echo "Caught exception: ", $e->getMessage() , "\n";
    }

    but got this error:

    Parse error: parse error, unexpected '{' ...

    It doesn't like my use of "try - catch".
    Why isn't "try - catch" documented?
    I found only one reference; (under "Exceptions ").


    Comment

    • Rik

      #3
      Re: .php5 versus .php

      On Thu, 15 Feb 2007 18:12:30 +0100, McKirahan <News@McKirahan .comwrote:
      >Is there a way to reliably determine if the ".php5" extension
      >must be used on a server? Perhaps via a "phpinfo()" value?
      >>
      I tried this (to not write to the file in the function isn't supported):
      >
      try {
      file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
      } catch (Exception $e) {
      echo "Caught exception: ", $e->getMessage() , "\n";
      }
      >
      but got this error:
      >
      Parse error: parse error, unexpected '{' ...
      >
      It doesn't like my use of "try - catch".
      Why isn't "try - catch" documented?
      I found only one reference; (under "Exceptions ").
      try - catch is only usefull for Exceptions, and hence that's where they're
      found. Also, Exceptions are introduced in PHP5, so that's no way to fall
      back to PHP4.

      Usefull for determening current PHP / newer functionality:
      <http://www.php.net/phpversion>
      <http://pear.php.net/package/PHP_Compat>

      Now, I have no idea how to find out the addtype declarations in apaches
      configuration with PHP, but this cumbersome workaround will probably work:

      ----checktype.php5--
      echo PHP_VERSION;
      --------------------

      ---check.php--------
      echo "Current .php version is ".PHP_VERSION." \n";
      $path = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERV ER['PHP_SELF']).'/';
      $php5 = file_get_conten ts($path.'check type.php5');
      if(preg_match('/^<\?/',$php5)){
      echo ".php5 is not supported as an extention";
      } else {
      echo ".php5 uses version ".$php5;
      $result = version_compare (PHP_VERSION,$p hp5);
      if($result == 0){
      echo "\nversions are equal";
      } else {
      echo "\nversion used for .php5 is ".(($result ==-1)?'higher':'lo wer');
      }
      }
      --------------------

      --
      Rik Wasmus

      Comment

      • Kimmo Laine

        #4
        Re: .php5 versus .php

        McKirahan kirjoitti:
        "McKirahan" <News@McKirahan .comwrote in message
        news:dO6dnRHVOf LPGknYnZ2dnUVZ_ uy3nZ2d@comcast .com...
        >I am working in two environments neither configuration of
        >which I can change; one's my Web host the other a client.
        >>
        >My Web host requires the use of the ".php5" extension
        >to use PHP v5.1.4; where ".php" is used for PHP v4.3.11.
        >My client supports PHP v5.2.0 with the ".php" extension.
        >>
        >Is there a way to reliably determine if the ".php5" extension
        >must be used on a server? Perhaps via a "phpinfo()" value?
        >>
        >I have a page that uses the v5 function "file_put_conte nts()".
        >(I like it's LOCK_EX feature.)
        >>
        >Thanks in advance.
        >
        >
        I tried this (to not write to the file in the function isn't supported):
        >
        try {
        file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
        } catch (Exception $e) {
        echo "Caught exception: ", $e->getMessage() , "\n";
        }
        >
        but got this error:
        >
        Parse error: parse error, unexpected '{' ...
        >
        It doesn't like my use of "try - catch".
        Why isn't "try - catch" documented?
        I found only one reference; (under "Exceptions ").
        >
        >
        Don't know if these help you any but two observations:

        1) you can get the version of php with phpversion();


        2) You can test wether a function exists with

        if(function_exi sts('file_put_c ontents')){
        file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
        } else {
        echo "craptastic !";
        }


        --
        "En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
        spam@outolempi. net | Gedoon-S @ IRCnet | rot13(xvzzb@bhg byrzcv.arg)

        Comment

        • shimmyshack

          #5
          Re: .php5 versus .php

          On Feb 15, 6:05 pm, Kimmo Laine <s...@outolempi .netwrote:
          McKirahan kirjoitti:
          >
          >
          >
          "McKirahan" <N...@McKirahan .comwrote in message
          news:dO6dnRHVOf LPGknYnZ2dnUVZ_ uy3nZ2d@comcast .com...
          I am working in two environments neither configuration of
          which I can change; one's my Web host the other a client.
          >
          My Web host requires the use of the ".php5" extension
          to use PHP v5.1.4; where ".php" is used for PHP v4.3.11.
          My client supports PHP v5.2.0 with the ".php" extension.
          >
          Is there a way to reliably determine if the ".php5" extension
          must be used on a server? Perhaps via a "phpinfo()" value?
          >
          I have a page that uses the v5 function "file_put_conte nts()".
          (I like it's LOCK_EX feature.)
          >
          Thanks in advance.
          >
          I tried this (to not write to the file in the function isn't supported):
          >
          try {
          file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
          } catch (Exception $e) {
          echo "Caught exception: ", $e->getMessage() , "\n";
          }
          >
          but got this error:
          >
          Parse error: parse error, unexpected '{' ...
          >
          It doesn't like my use of "try - catch".
          Why isn't "try - catch" documented?
          I found only one reference; (under "Exceptions ").
          >
          Don't know if these help you any but two observations:
          >
          1) you can get the version of php with phpversion();http://fi.php.net/manual/en/function.phpversion.php
          >
          2) You can test wether a function exists with
          >
          if(function_exi sts('file_put_c ontents')){
          file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);} else {
          >
          echo "craptastic !";
          >
          }
          >
          --
          "En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
          s...@outolempi. net | Gedoon-S @ IRCnet | rot13(x...@bhgb yrzcv.arg)
          also your code had a typo in it:

          try
          {
          file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
          }
          catch (Exception $e)
          {
          echo "Caught exception: ". $e->getMessage() , "\n";
          } |
          _______________ ___________|
          (should have been a dot after caught exception)

          as for .php5, just use an .htaccess file to rewrite all extensions of
          one sort to the other, whatever suits. 1and1 are like this, but the
          htaccess rewrite rules work fine.

          Comment

          • shimmyshack

            #6
            Re: .php5 versus .php

            On Feb 15, 6:05 pm, Kimmo Laine <s...@outolempi .netwrote:
            McKirahan kirjoitti:
            >
            >
            >
            "McKirahan" <N...@McKirahan .comwrote in message
            news:dO6dnRHVOf LPGknYnZ2dnUVZ_ uy3nZ2d@comcast .com...
            I am working in two environments neither configuration of
            which I can change; one's my Web host the other a client.
            >
            My Web host requires the use of the ".php5" extension
            to use PHP v5.1.4; where ".php" is used for PHP v4.3.11.
            My client supports PHP v5.2.0 with the ".php" extension.
            >
            Is there a way to reliably determine if the ".php5" extension
            must be used on a server? Perhaps via a "phpinfo()" value?
            >
            I have a page that uses the v5 function "file_put_conte nts()".
            (I like it's LOCK_EX feature.)
            >
            Thanks in advance.
            >
            I tried this (to not write to the file in the function isn't supported):
            >
            try {
            file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
            } catch (Exception $e) {
            echo "Caught exception: ", $e->getMessage() , "\n";
            }
            >
            but got this error:
            >
            Parse error: parse error, unexpected '{' ...
            >
            It doesn't like my use of "try - catch".
            Why isn't "try - catch" documented?
            I found only one reference; (under "Exceptions ").
            >
            Don't know if these help you any but two observations:
            >
            1) you can get the version of php with phpversion();http://fi.php.net/manual/en/function.phpversion.php
            >
            2) You can test wether a function exists with
            >
            if(function_exi sts('file_put_c ontents')){
            file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);} else {
            >
            echo "craptastic !";
            >
            }
            >
            --
            "En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
            s...@outolempi. net | Gedoon-S @ IRCnet | rot13(x...@bhgb yrzcv.arg)
            oh and of course, dont forget the other typo ,->. further on the same
            line!!

            Comment

            • McKirahan

              #7
              Re: .php5 versus .php

              "Rik" <luiheidsgoeroe @hotmail.comwro te in message
              news:op.tnsw4xt iqnv3q9@misant. ..
              On Thu, 15 Feb 2007 18:12:30 +0100, McKirahan <News@McKirahan .comwrote:
              >Is there a way to reliably determine if the ".php5" extension
              >must be used on a server? Perhaps via a "phpinfo()" value?
              >>
              I tried this (to not write to the file in the function isn't supported):
              >
              try {
              file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
              } catch (Exception $e) {
              echo "Caught exception: ", $e->getMessage() , "\n";
              }
              >
              but got this error:
              >
              Parse error: parse error, unexpected '{' ...
              >
              It doesn't like my use of "try - catch".
              Why isn't "try - catch" documented?
              I found only one reference; (under "Exceptions ").
              try - catch is only usefull for Exceptions, and hence that's where they're
              found. Also, Exceptions are introduced in PHP5, so that's no way to fall
              back to PHP4.

              Usefull for determening current PHP / newer functionality:
              <http://www.php.net/phpversion>
              <http://pear.php.net/package/PHP_Compat>

              Now, I have no idea how to find out the addtype declarations in apaches
              configuration with PHP, but this cumbersome workaround will probably work:

              ----checktype.php5--
              echo PHP_VERSION;
              --------------------

              ---check.php--------
              echo "Current .php version is ".PHP_VERSION." \n";
              $path = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERV ER['PHP_SELF']).'/';
              $php5 = file_get_conten ts($path.'check type.php5');
              if(preg_match('/^<\?/',$php5)){
              echo ".php5 is not supported as an extention";
              } else {
              echo ".php5 uses version ".$php5;
              $result = version_compare (PHP_VERSION,$p hp5);
              if($result == 0){
              echo "\nversions are equal";
              } else {
              echo "\nversion used for .php5 is ".(($result ==-1)?'higher':'lo wer');
              }
              }
              --------------------

              Thanks for the information.


              Comment

              • McKirahan

                #8
                Re: .php5 versus .php

                "Kimmo Laine" <spam@outolempi .netwrote in message
                news:er27ds$1ja $1@nyytiset.pp. htv.fi...
                McKirahan kirjoitti:
                "McKirahan" <News@McKirahan .comwrote in message
                news:dO6dnRHVOf LPGknYnZ2dnUVZ_ uy3nZ2d@comcast .com...
                I am working in two environments neither configuration of
                which I can change; one's my Web host the other a client.
                >
                My Web host requires the use of the ".php5" extension
                to use PHP v5.1.4; where ".php" is used for PHP v4.3.11.
                My client supports PHP v5.2.0 with the ".php" extension.
                >
                Is there a way to reliably determine if the ".php5" extension
                must be used on a server? Perhaps via a "phpinfo()" value?
                >
                I have a page that uses the v5 function "file_put_conte nts()".
                (I like it's LOCK_EX feature.)
                >
                Thanks in advance.

                I tried this (to not write to the file in the function isn't supported):

                try {
                file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
                } catch (Exception $e) {
                echo "Caught exception: ", $e->getMessage() , "\n";
                }

                but got this error:

                Parse error: parse error, unexpected '{' ...

                It doesn't like my use of "try - catch".
                Why isn't "try - catch" documented?
                I found only one reference; (under "Exceptions ").
                >
                Don't know if these help you any but two observations:
                >
                1) you can get the version of php with phpversion();

                >
                2) You can test wether a function exists with
                >
                if(function_exi sts('file_put_c ontents')){
                file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
                } else {
                echo "craptastic !";
                }
                Thanks! I'm going to use "function_exist s()".


                Comment

                • McKirahan

                  #9
                  Re: .php5 versus .php

                  "shimmyshac k" <matt.farey@gma il.comwrote in message
                  news:1171577754 .774839.155030@ a34g2000cwb.goo glegroups.com.. .
                  On Feb 15, 6:05 pm, Kimmo Laine <s...@outolempi .netwrote:

                  [snip]
                  "En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
                  s...@outolempi. net | Gedoon-S @ IRCnet | rot13(x...@bhgb yrzcv.arg)
                  oh and of course, dont forget the other typo ,->. further on the same
                  line!!


                  Please notify the PHP Documentation Group; here's their example:

                  Chapter 20. Exceptions

                  Example 20-1. Throwing an Exception

                  <?php
                  try {
                  $error = 'Always throw this error';
                  throw new Exception($erro r);

                  // Code following an exception is not executed.
                  echo 'Never executed';

                  } catch (Exception $e) {
                  echo 'Caught exception: ', $e->getMessage() , "\n";
                  }

                  // Continue execution
                  echo 'Hello World';
                  ?>



                  Comment

                  • Rik

                    #10
                    Re: .php5 versus .php

                    On Fri, 16 Feb 2007 02:48:06 +0100, McKirahan <News@McKirahan .comwrote:
                    Thanks! I'm going to use "function_exist s()".
                    Don't forget PEAR PHP_Compat, saves a lot of headaches in trying to write
                    your own workarounds...
                    --
                    Rik Wasmus

                    Comment

                    • Kimmo Laine

                      #11
                      Re: .php5 versus .php

                      "McKirahan" <News@McKirahan .comwrote in message
                      news:FcidnT_ei-gIkUjYnZ2dnUVZ_ syunZ2d@comcast .com...
                      "shimmyshac k" <matt.farey@gma il.comwrote in message
                      news:1171577754 .774839.155030@ a34g2000cwb.goo glegroups.com.. .
                      On Feb 15, 6:05 pm, Kimmo Laine <s...@outolempi .netwrote:
                      >
                      [snip]
                      >
                      >"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
                      >s...@outolempi .net | Gedoon-S @ IRCnet | rot13(x...@bhgb yrzcv.arg)
                      >
                      oh and of course, dont forget the other typo ,->. further on the same
                      line!!
                      >
                      >
                      Please notify the PHP Documentation Group; here's their example:
                      >
                      Chapter 20. Exceptions
                      >
                      Example 20-1. Throwing an Exception
                      >
                      <?php
                      try {
                      $error = 'Always throw this error';
                      throw new Exception($erro r);
                      >
                      // Code following an exception is not executed.
                      echo 'Never executed';
                      >
                      } catch (Exception $e) {
                      echo 'Caught exception: ', $e->getMessage() , "\n";
                      }

                      The gag here is that when using a dot, you're concatenating two strings,
                      when using a comma your passing two (or more) arguments to echo, so the
                      comma thing only works with echo which is capable of recieveing arbitrary
                      number of parameters, unlike print for example. Thus print('foo','ba r')
                      doesn't work while echo('foo','bar ') does. Actually it might save just a
                      teeny bit of cpu cycles if the strings aren't concatenated but instead
                      passed as separate parameters. Go figure. For the sake of readability, using
                      dots consistently might be wise.

                      --
                      "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
                      http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
                      spam@outolempi. net | rot13(xvzzb@bhg byrzcv.arg)


                      Comment

                      • McKirahan

                        #12
                        Re: .php5 versus .php

                        "Rik" <luiheidsgoeroe @hotmail.comwro te in message
                        news:op.tnto7jx 2qnv3q9@misant. ..
                        On Fri, 16 Feb 2007 02:48:06 +0100, McKirahan <News@McKirahan .comwrote:
                        Thanks! I'm going to use "function_exist s()".
                        >
                        Don't forget PEAR PHP_Compat, saves a lot of headaches in trying to write
                        your own workarounds...
                        --
                        Rik Wasmus
                        I'm rather new to PHP (though I know JS and VBS);
                        how can I determine if PEAR is installed on the Web server?


                        Comment

                        • shimmyshack

                          #13
                          Re: .php5 versus .php

                          On Feb 16, 6:37 am, "Kimmo Laine" <s...@outolempi .netwrote:
                          "McKirahan" <N...@McKirahan .comwrote in message
                          >
                          news:FcidnT_ei-gIkUjYnZ2dnUVZ_ syunZ2d@comcast .com...
                          >
                          >
                          >
                          "shimmyshac k" <matt.fa...@gma il.comwrote in message
                          news:1171577754 .774839.155030@ a34g2000cwb.goo glegroups.com.. .
                          On Feb 15, 6:05 pm, Kimmo Laine <s...@outolempi .netwrote:
                          >
                          [snip]
                          >
                          "En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
                          s...@outolempi. net | Gedoon-S @ IRCnet | rot13(x...@bhgb yrzcv.arg)
                          >
                          oh and of course, dont forget the other typo ,->. further on the same
                          line!!
                          >
                          Please notify the PHP Documentation Group; here's their example:
                          >
                          Chapter 20. Exceptions
                          >
                          Example 20-1. Throwing an Exception
                          >
                          <?php
                          try {
                          $error = 'Always throw this error';
                          throw new Exception($erro r);
                          >
                          // Code following an exception is not executed.
                          echo 'Never executed';
                          >
                          } catch (Exception $e) {
                          echo 'Caught exception: ', $e->getMessage() , "\n";
                          }
                          >
                          The gag here is that when using a dot, you're concatenating two strings,
                          when using a comma your passing two (or more) arguments to echo, so the
                          comma thing only works with echo which is capable of recieveing arbitrary
                          number of parameters, unlike print for example. Thus print('foo','ba r')
                          doesn't work while echo('foo','bar ') does. Actually it might save just a
                          teeny bit of cpu cycles if the strings aren't concatenated but instead
                          passed as separate parameters. Go figure. For the sake of readability, using
                          dots consistently might be wise.
                          >
                          --
                          "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpkhttp://outolempi.net/ahdistus/- Satunnaisesti päivittyvä nettisarjis
                          s...@outolempi. net | rot13(x...@bhgb yrzcv.arg)
                          yeah, do you know in years of php programming I've only ever
                          concatenated strings when using echo - my bad - although I always use
                          ' instead of " so brownie points there huh! perhaps its time to go
                          read up on some other functions too! sorry for any confusion, I don't
                          think ill be notifying the php doc group!

                          Comment

                          • Rik

                            #14
                            Re: .php5 versus .php

                            On Sat, 17 Feb 2007 00:54:36 +0100, shimmyshack <matt.farey@gma il.com>
                            wrote:
                            yeah, do you know in years of php programming I've only ever
                            concatenated strings when using echo - my bad - although I always use
                            ' instead of " so brownie points there huh! perhaps its time to go
                            read up on some other functions too! sorry for any confusion, I don't
                            think ill be notifying the php doc group!
                            echo is not a function, it's a construct :P
                            Hence the unexpecyed behaviour.
                            --
                            Rik Wasmus

                            Comment

                            • Rik

                              #15
                              Re: .php5 versus .php

                              McKirahan <News@McKirahan .comwrote:
                              I'm rather new to PHP (though I know JS and VBS);
                              how can I determine if PEAR is installed on the Web server?
                              All coding issues aside: easiest and fastest way is just to ask you hoster.


                              --
                              Rik Wasmus

                              Comment

                              Working...