All of this can be found at http://www.devnetwork.net/forums/viewtopic.php?p=8841
Now this morning when I got to work and did a little rummaging through my file system (/home/Big. And yes, I got root!), I found the little script I wrote to test some of this and realized something. You could almost totally mimic the use of structures in php with out the penalty or overhead of a class by doing the below.
Code: Select all
<?php
# A factory class for a structure
class Struct
{
# This is what will create the structure
function create_Struct($struct_array)
{
$struct_array=array(
age => 0,
name => "",
initials => "",
sex => ""
);
return $struct_array;
}
}
# Create the factory class
$my_struct = new Struct;
# Create one structure/array
$yam = $my_struct->create_Struct($yam);
# Create another structure/array
$blam = $my_struct->create_Struct($blam);
# Test the creation of these structure/arrays
print_r($yam);
print_r($blam);
?>However, just like structures, this acts as a template so that whenever another one is needed, you just run the create_Struct() method as above.
Now you could so something like this to act like a pointer.
Code: Select all
# This will work as a pointer.
$pointer = &$yam;
print_r($pointer);Code: Select all
printf("%s", pointer->sex)Code: Select all
echo(pointerїsex]);The factory class could also be a function too.
If any of you C guys out there see any issues with this, pipe up.
Later on,
BDKR