Object without class

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

    Object without class

    Hello all!

    I have a question regarding next few lines of code.

    <?php
    $person->name = "John Doe";
    $person->age = "26";
    ?>

    What does this piece of code actually do? It seems to create object $person,
    but i am not shure if i can create objects without defining class first? I'm
    little confused here :) This reminds me of structures in C...
    Thanx!

    --
    Relaxen und watch das blinkenlights.. .


  • CountScubula

    #2
    Re: Object without class

    "Cpt. Zeep" <zeep@nemame.co m> wrote in message
    news:bt8p8v$cvn $1@bagan.srce.h r...[color=blue]
    > Hello all!
    >
    > I have a question regarding next few lines of code.
    >
    > <?php
    > $person->name = "John Doe";
    > $person->age = "26";
    > ?>
    >
    > What does this piece of code actually do? It seems to create object[/color]
    $person,[color=blue]
    > but i am not shure if i can create objects without defining class first?[/color]
    I'm[color=blue]
    > little confused here :) This reminds me of structures in C...
    > Thanx!
    >
    > --
    > Relaxen und watch das blinkenlights.. .
    >
    >[/color]

    nothing more than an empty object with variables in it, 2 in this case

    php is realy nice about auto.... (I forget the word) Basicaly, when you
    first use something, it will be created for you right then. This is one
    major differnce from a script language and a compiled one. dont get me
    wrong, you can do this in a high level language, however for really tight
    code compiling. say for a microchip, you do not want the overhead of
    auto-defining. you simple state how big a varaible is going to be, so it
    makes room for it.




    --
    Mike Bradley
    http://gzen.myhq.info -- free online php tools


    Comment

    • Jochen Buennagel

      #3
      Re: Object without class

      Cpt. Zeep wrote:[color=blue]
      > <?php
      > $person->name = "John Doe";
      > $person->age = "26";
      > ?>
      >
      > What does this piece of code actually do? It seems to create object $person,
      > but i am not shure if i can create objects without defining class first?[/color]

      try <?php echo get_class($pers on); ?>

      It will output "stdClass" which is the pseudo-class PHP uses for
      uninitialized objects.

      Jochen

      Comment

      • TG

        #4
        Re: Object without class

        CountScubula if you are the one who runs the gzentools.com site, your e-mail
        address of info@gzentools. com is bouncing, I am getting a message that says
        relaying denied. I sent you an email that bounces with this error message,
        how can I contact that site?

        "CountScubu la" <me@scantek.hot mail.com> wrote in message
        news:p3SJb.5906 $CI3.711@newssv r29.news.prodig y.com...[color=blue]
        > "Cpt. Zeep" <zeep@nemame.co m> wrote in message
        > news:bt8p8v$cvn $1@bagan.srce.h r...[color=green]
        > > Hello all!
        > >
        > > I have a question regarding next few lines of code.
        > >
        > > <?php
        > > $person->name = "John Doe";
        > > $person->age = "26";
        > > ?>
        > >
        > > What does this piece of code actually do? It seems to create object[/color]
        > $person,[color=green]
        > > but i am not shure if i can create objects without defining class first?[/color]
        > I'm[color=green]
        > > little confused here :) This reminds me of structures in C...
        > > Thanx!
        > >
        > > --
        > > Relaxen und watch das blinkenlights.. .
        > >
        > >[/color]
        >
        > nothing more than an empty object with variables in it, 2 in this case
        >
        > php is realy nice about auto.... (I forget the word) Basicaly, when you
        > first use something, it will be created for you right then. This is one
        > major differnce from a script language and a compiled one. dont get me
        > wrong, you can do this in a high level language, however for really tight
        > code compiling. say for a microchip, you do not want the overhead of
        > auto-defining. you simple state how big a varaible is going to be, so it
        > makes room for it.
        >
        >
        >
        >
        > --
        > Mike Bradley
        > http://gzen.myhq.info -- free online php tools
        >
        >[/color]


        Comment

        • CountScubula

          #5
          Re: Object without class

          "TG" <tgillette1@cox .net> wrote in message
          news:xBXJb.2305 8$JD6.795@laker ead04...[color=blue]
          > CountScubula if you are the one who runs the gzentools.com site, your[/color]
          e-mail[color=blue]
          > address of info@gzentools. com is bouncing, I am getting a message that[/color]
          says[color=blue]
          > relaying denied. I sent you an email that bounces with this error message,
          > how can I contact that site?
          >[/color]

          I need to stop configuring stuff when I am sleep deprieved, I needed to
          restart sendmail, it did not notice the new entry in local-host-names.

          thanks for the info, it is working now.

          --
          Mike Bradley
          http://gzen.myhq.info -- free online php tools


          Comment

          • Cpt. Zeep

            #6
            Re: Object without class

            Thanx everybody!

            --
            Relaxen und watch das blinkenlights.. .


            Comment

            • Chung Leong

              #7
              Re: Object without class

              The term you're looking for is "autovivication ." Ok, I had to look it up in
              my camel book.

              Uzytkownik "CountScubu la" <me@scantek.hot mail.com> napisal w wiadomosci
              news:p3SJb.5906 $CI3.711@newssv r29.news.prodig y.com...
              [color=blue]
              > php is realy nice about auto.... (I forget the word) Basicaly, when you
              > first use something, it will be created for you right then. This is one
              > major differnce from a script language and a compiled one. dont get me
              > wrong, you can do this in a high level language, however for really tight
              > code compiling. say for a microchip, you do not want the overhead of
              > auto-defining. you simple state how big a varaible is going to be, so it
              > makes room for it.
              >
              >
              >
              >
              > --
              > Mike Bradley
              > http://gzen.myhq.info -- free online php tools
              >
              >[/color]


              Comment

              Working...