structures in php ? – PHP

  php

Q(Question):

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_INFORMATION
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_INFORMATION
Many Thanks

Adrian Parker

A(Answer):

Adrian Parker wrote:

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_INFORMATION
Dim Bias As Integer
Dim StandardBias As Integer
Dim DaylightBias As Integer
Dim StandardDate As SYSTEMTIME
Dim DaylightDate As SYSTEMTIME
End Structure

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($year, $month, $dayOfWeek, [etc…]) {
$this->wYear = $year;
$this->wMonth = $month;
$this->wDayOfWeek = $dayOfWeek;

etc…
}
}
Also, if I read a binary value from the registry,

The *what* ?-)
how would I then

convert it to a variable of type TIME_ZONE_INFORMATION

ask a MS-Windows group…

Bruno

A(Answer):

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" <bd*****************@free.quelquepart.fr> wrote in message news:40***********************@news.free.fr…

Adrian Parker wrote:

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_INFORMATION
Dim Bias As Integer
Dim StandardBias As Integer
Dim DaylightBias As Integer
Dim StandardDate As SYSTEMTIME
Dim DaylightDate As SYSTEMTIME
End Structure

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($year, $month, $dayOfWeek, [etc…]) {
$this->wYear = $year;
$this->wMonth = $month;
$this->wDayOfWeek = $dayOfWeek;

etc…
}
}

Also, if I read a binary value from the registry,

The *what* ?-)

how would I then

convert it to a variable of type TIME_ZONE_INFORMATION

ask a MS-Windows group…

Bruno

A(Answer):

Adrian Parker wrote:

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_INFORMATION
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_INFORMATION
Many Thanks

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

A(Answer):

Thanks for the pointer.

"Amir Khawaja" <am**@gorebels.net> wrote in message news:B6LSb.12713$QJ3.11343@fed1read04…

Adrian Parker wrote:

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_INFORMATION
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_INFORMATION
Many Thanks

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

A(Answer):

Adrian Parker wrote:

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 ?

I’m not sure this will help, but you may want to have a look at :
http://www.php.net/manual/en/function.pack.php
http://www.php.net/manual/en/function.unpack.php
http://www.php.net/manual/en/function.bin2hex.php

Else you may have to manually parse your binary data.

About windows registry, STFW :
http://codingtheweb.partners.phpclas…kage/1426.html

HTH
Bruno

A(Answer):

"Adrian Parker" <ap******@nospam.com> wrote in message news:<gI*****************@news-binary.blueyonder.co.uk>…

How do you create data structures in php ?

<snip>

Someone already gave you the hint. Anyway, see
<http://groups.google.com/groups?threadm=abc4d8b8.0401050125.4a59d9fc%40post ing.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

LEAVE A COMMENT