structures in php ?

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

    structures in php ?

    How do you create data structures in php ?

    i.e. how would I create the following two vb structures in php ?

    Structure SYSTEMTIME
    Dim wYear As Short
    Dim wMonth As Short
    Dim wDayOfWeek As Short
    Dim wDay As Short
    Dim wHour As Short
    Dim wMinute As Short
    Dim wSecond As Short
    Dim wMilliseconds As Short
    End Structure

    Private Structure TIME_ZONE_INFOR MATION
    Dim Bias As Integer
    Dim StandardBias As Integer
    Dim DaylightBias As Integer
    Dim StandardDate As SYSTEMTIME
    Dim DaylightDate As SYSTEMTIME
    End Structure

    Also, if I read a binary value from the registry, how would I then convert it to a variable of type TIME_ZONE_INFOR MATION


    Many Thanks
    --
    Adrian Parker


  • Bruno Desthuilliers

    #2
    Re: structures in php ?

    Adrian Parker wrote:[color=blue]
    > How do you create data structures in php ?
    >
    > i.e. how would I create the following two vb structures in php ?
    >
    > Structure SYSTEMTIME
    > Dim wYear As Short
    > Dim wMonth As Short
    > Dim wDayOfWeek As Short
    > Dim wDay As Short
    > Dim wHour As Short
    > Dim wMinute As Short
    > Dim wSecond As Short
    > Dim wMilliseconds As Short
    > End Structure
    >
    > Private Structure TIME_ZONE_INFOR MATION
    > Dim Bias As Integer
    > Dim StandardBias As Integer
    > Dim DaylightBias As Integer
    > Dim StandardDate As SYSTEMTIME
    > Dim DaylightDate As SYSTEMTIME
    > End Structure[/color]

    Two solutions :
    1/ the Q&D way : use an associative array :
    $sys_time = Array();
    $sys_time['wYear'] = 2004;
    $sys_time['wMonth'] = 12;

    etc...

    2/ the clean way : use classes :

    class SystemTime {
    function SystemTime($yea r, $month, $dayOfWeek, [etc...]) {
    $this->wYear = $year;
    $this->wMonth = $month;
    $this->wDayOfWeek = $dayOfWeek;

    etc...
    }
    }
    [color=blue]
    > Also, if I read a binary value from the registry,[/color]

    The *what* ?-)
    [color=blue]
    > how would I then[/color]
    convert it to a variable of type TIME_ZONE_INFOR MATION

    ask a MS-Windows group...

    Bruno

    Comment

    • Adrian Parker

      #3
      Re: structures in php ?

      Ok, lets put it another way.

      Say I have a blob in a db that was populated from another source.

      when I select the blob, I just have binary data.. how do I split that up into the individual structure components ?


      "Bruno Desthuilliers" <bdesth.quelque chose@free.quel quepart.fr> wrote in message news:401b7b00$0 $11219$626a54ce @news.free.fr.. .[color=blue]
      > Adrian Parker wrote:[color=green]
      > > How do you create data structures in php ?
      > >
      > > i.e. how would I create the following two vb structures in php ?
      > >
      > > Structure SYSTEMTIME
      > > Dim wYear As Short
      > > Dim wMonth As Short
      > > Dim wDayOfWeek As Short
      > > Dim wDay As Short
      > > Dim wHour As Short
      > > Dim wMinute As Short
      > > Dim wSecond As Short
      > > Dim wMilliseconds As Short
      > > End Structure
      > >
      > > Private Structure TIME_ZONE_INFOR MATION
      > > Dim Bias As Integer
      > > Dim StandardBias As Integer
      > > Dim DaylightBias As Integer
      > > Dim StandardDate As SYSTEMTIME
      > > Dim DaylightDate As SYSTEMTIME
      > > End Structure[/color]
      >
      > Two solutions :
      > 1/ the Q&D way : use an associative array :
      > $sys_time = Array();
      > $sys_time['wYear'] = 2004;
      > $sys_time['wMonth'] = 12;
      >
      > etc...
      >
      > 2/ the clean way : use classes :
      >
      > class SystemTime {
      > function SystemTime($yea r, $month, $dayOfWeek, [etc...]) {
      > $this->wYear = $year;
      > $this->wMonth = $month;
      > $this->wDayOfWeek = $dayOfWeek;
      >
      > etc...
      > }
      > }
      >[color=green]
      > > Also, if I read a binary value from the registry,[/color]
      >
      > The *what* ?-)
      >[color=green]
      > > how would I then[/color]
      > convert it to a variable of type TIME_ZONE_INFOR MATION
      >
      > ask a MS-Windows group...
      >
      > Bruno
      >[/color]


      Comment

      • Amir Khawaja

        #4
        Re: structures in php ?

        Adrian Parker wrote:[color=blue]
        > How do you create data structures in php ?
        >
        > i.e. how would I create the following two vb structures in php ?
        >
        > Structure SYSTEMTIME
        > Dim wYear As Short
        > Dim wMonth As Short
        > Dim wDayOfWeek As Short
        > Dim wDay As Short
        > Dim wHour As Short
        > Dim wMinute As Short
        > Dim wSecond As Short
        > Dim wMilliseconds As Short
        > End Structure
        >
        > Private Structure TIME_ZONE_INFOR MATION
        > Dim Bias As Integer
        > Dim StandardBias As Integer
        > Dim DaylightBias As Integer
        > Dim StandardDate As SYSTEMTIME
        > Dim DaylightDate As SYSTEMTIME
        > End Structure
        >
        > Also, if I read a binary value from the registry, how would I then convert it to a variable of type TIME_ZONE_INFOR MATION
        >
        >
        > Many Thanks[/color]

        PHP does not have support for Structures or structs in the traditional
        sense. You can use an associative array instead to simulate the
        structure and it's members.

        --
        Amir Khawaja.

        ----------------------------------
        Rules are written for those who lack the ability to truly reason, But
        for those who can, the rules become nothing more than guidelines, And
        live their lives governed not by rules but by reason.
        - James McGuigan

        Comment

        • Adrian Parker

          #5
          Re: structures in php ?

          Thanks for the pointer.

          "Amir Khawaja" <amir@gorebels. net> wrote in message news:B6LSb.1271 3$QJ3.11343@fed 1read04...[color=blue]
          > Adrian Parker wrote:[color=green]
          > > How do you create data structures in php ?
          > >
          > > i.e. how would I create the following two vb structures in php ?
          > >
          > > Structure SYSTEMTIME
          > > Dim wYear As Short
          > > Dim wMonth As Short
          > > Dim wDayOfWeek As Short
          > > Dim wDay As Short
          > > Dim wHour As Short
          > > Dim wMinute As Short
          > > Dim wSecond As Short
          > > Dim wMilliseconds As Short
          > > End Structure
          > >
          > > Private Structure TIME_ZONE_INFOR MATION
          > > Dim Bias As Integer
          > > Dim StandardBias As Integer
          > > Dim DaylightBias As Integer
          > > Dim StandardDate As SYSTEMTIME
          > > Dim DaylightDate As SYSTEMTIME
          > > End Structure
          > >
          > > Also, if I read a binary value from the registry, how would I then convert it to a variable of type TIME_ZONE_INFOR MATION
          > >
          > >
          > > Many Thanks[/color]
          >
          > PHP does not have support for Structures or structs in the traditional
          > sense. You can use an associative array instead to simulate the
          > structure and it's members.
          >
          > --
          > Amir Khawaja.
          >
          > ----------------------------------
          > Rules are written for those who lack the ability to truly reason, But
          > for those who can, the rules become nothing more than guidelines, And
          > live their lives governed not by rules but by reason.
          > - James McGuigan[/color]


          Comment

          • Bruno Desthuilliers

            #6
            Re: structures in php ?

            Adrian Parker wrote:[color=blue]
            > Ok, lets put it another way.
            >
            > Say I have a blob in a db that was populated from another source.
            >
            > when I select the blob, I just have binary data.. how do I split that up into the individual structure components ?
            >[/color]

            I'm not sure this will help, but you may want to have a look at :


            Convert binary data into hexadecimal representation


            Else you may have to manually parse your binary data.

            About windows registry, STFW :


            HTH
            Bruno

            Comment

            • R. Rajesh Jeba Anbiah

              #7
              Re: structures in php ?

              "Adrian Parker" <apparker@nospa m.com> wrote in message news:<gIKSb.473 4$ny4.4068@news-binary.blueyond er.co.uk>...[color=blue]
              > How do you create data structures in php ?
              >[/color]
              <snip>

              Someone already gave you the hint. Anyway, see
              <http://groups.google.c om/groups?threadm= abc4d8b8.040105 0125.4a59d9fc%4 0posting.google .com>
              for such previous discussion.

              --
              "I don't believe in the God who doesn't give me food, but shows me
              heaven!" -- Swami Vivekanandha
              Email: rrjanbiah-at-Y!com

              Comment

              Working...