Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

Structures in PHP

General discussions related to php

Moderators: macek, egami, gesf

Structures in PHP

Postby tmpdev » Tue Jun 17, 2003 8:34 am

Hello there...

I am used to program in C and was thinking:

The keyword struct does not exist (at least not exact) I have
been looking through the PHP-helpfile and have not find anything like that (beside class)

Now my problem is really that I want to use binary-mode files. That is creating several post of exact the same size. And the helpfile is hard on me cause I cant figure it out. So you guys here have helped me in the past so :)

(I am not at home with my PHP-editor right now so I cant test if there is exact matches. If there is a exact match of a function dont say anything about it cause I will find out for myself... else please tell me the replacement procedure for that func)

The things I am looking for is:

struct type

Hmm, perhaps (if sizeof() exists) there is only to use class instead of struct? Well well...
New php-forum User
New php-forum User
Posts: 3
Joined: Sun May 04, 2003 1:26 am

Postby Joan Garnet » Tue Jun 17, 2003 11:23 am

sizeof() does exist, but it's about array length, not the actual size in memory.

struct ¿?¿? what is it for in C ??
User avatar
Joan Garnet
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby Redcircle » Tue Jun 17, 2003 2:35 pm

if you are trying to find out the size of a file use filesize()
User avatar
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Postby tmpdev » Fri Jul 04, 2003 11:37 pm

Well, struct in C was used for making own types of variables such as exampel a car-structure which would be made up of three parts, car licenseplate, yearmodel and type:

struct Car {
int yearmodel;
char licenseplate[7];
char type[20];


this way I could save Different cars in a binaryfile and find the
correct post by using sizeof(struct Car) multiplied by the nr the car has... and then copy the memory there to a temp Car struct which I then could use as I pleased. My problem is that this way makes it easier to keep track of a complicated object,
with different datatypes. But perhaps this can be done just with arrays, still the problem is I need fixed string sizes, even if the word is smaller. That is if I want to save and recover from a file...

Please need help on this one!
New php-forum User
New php-forum User
Posts: 3
Joined: Sun May 04, 2003 1:26 am

Return to PHP General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.