constant

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

    constant

    Hi folk

    I do this:

    define("a1", "b");
    echo a1
    $y = 1;
    $x = "a".$y
    echo contant($x);

    for the last line I get an error. How can I fix this?

    Cheers

    Nicolaas


  • Balazs Wellisch

    #2
    Re: constant

    >[color=blue]
    > define("a1", "b");
    > echo a1
    > $y = 1;
    > $x = "a".$y
    > echo contant($x);
    >
    > for the last line I get an error. How can I fix this?[/color]

    Just check your spelling and punctuation!

    define("a1", "b");
    echo a1;
    $y = 1;
    $x = "a".$y;
    echo constant($x);

    It works.

    Balazs


    Comment

    • joelbyrd@gmail.com

      #3
      Re: constant

      You're missing a semicolon on the line before the last - this will give
      an error on the last line.

      Comment

      • windandwaves

        #4
        Re: constant

        Balazs Wellisch wrote:[color=blue][color=green]
        >> define("a1", "b");
        >> echo a1
        >> $y = 1;
        >> $x = "a".$y
        >> echo contant($x);
        >>
        >> for the last line I get an error. How can I fix this?[/color]
        >
        > Just check your spelling and punctuation!
        >
        > define("a1", "b");
        > echo a1;
        > $y = 1;
        > $x = "a".$y;
        > echo constant($x);
        >
        > It works.
        >
        > Balazs[/color]

        it was actually just an example. In real life it is not working! It is a
        pretty old version of PHP, could that be it? It does recognise constant as
        a function though. It was all rather weird.


        Comment

        • Kimmo Laine

          #5
          Re: constant

          "windandwav es" <winandwaves@co ldmail.com> kirjoitti
          viestissä:1gnAf .18037$vH5.8887 81@news.xtra.co .nz...[color=blue]
          > Balazs Wellisch wrote:[color=green][color=darkred]
          >>> define("a1", "b");
          >>> echo a1
          >>> $y = 1;
          >>> $x = "a".$y
          >>> echo contant($x);
          >>>
          >>> for the last line I get an error. How can I fix this?[/color]
          >>
          >> Just check your spelling and punctuation!
          >>
          >> define("a1", "b");
          >> echo a1;
          >> $y = 1;
          >> $x = "a".$y;
          >> echo constant($x);
          >>
          >> It works.
          >>
          >> Balazs[/color]
          >
          > it was actually just an example. In real life it is not working! It is a
          > pretty old version of PHP, could that be it? It does recognise constant
          > as a function though. It was all rather weird.[/color]

          Constant() function is available since php 4.0.4


          --
          SETI @ Home - Donate your cpu's idle time to science.
          Further reading at <http://setiweb.ssl.ber keley.edu/>
          Kimmo Laine <antaatulla.sik anautaa@gmail.c om.NOSPAM.inval id>


          Comment

          • Chung Leong

            #6
            Re: constant

            It could be a bug. Try defining the constant as case-insensitive and
            see what happens. Got a dump on get_defined_con stants() too.

            Comment

            Working...