php-general Digest 11 Jul 2008 16:37:10 -0000 Issue 5563

Topics (messages 276637 through 276661):

Re: OT - RE: [PHP] scalable web gallery
        276637 by: Robert Cummings
        276653 by: tedd

Re: What font/size do you use for programming?
        276638 by: Robert Cummings
        276639 by: Robert Cummings
        276642 by: dg
        276644 by: Robert Cummings
        276645 by: dg
        276646 by: Robert Cummings

Re: scalable web gallery
        276640 by: Robert Cummings
        276643 by: paragasu
        276654 by: tedd

Re: how to change session timeout output text
        276641 by: Robert Cummings

Re: include_path, permissions question
        276647 by: Thodoris

apache/vhosts wuestion...
        276648 by: bruce
        276650 by: Wolf
        276652 by: Daniel Brown

date() and strtotime()
        276649 by: Fabian Frei
        276651 by: Bastien Koert

Question regarding OO
        276655 by: Yeti
        276656 by: Robert Cummings
        276658 by: Ted Wood
        276659 by: Ted Wood

Re: Relocating and POSTing
        276657 by: tedd
        276660 by: Alex Chamberlain
        276661 by: Daniel Brown

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
On Thu, 2008-07-10 at 12:06 -0500, Boyd, Todd M. wrote:
> > -----Original Message-----
> > From: Robert Cummings [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, July 10, 2008 11:24 AM
> > To: Boyd, Todd M.
> > Cc: Daniel Brown; [EMAIL PROTECTED]
> > Subject: Re: [PHP] OT - RE: [PHP] scalable web gallery
> > 
> > On Thu, 2008-07-10 at 10:18 -0500, Boyd, Todd M. wrote:
> > > > -----Original Message-----
> > > > From: Daniel Brown [mailto:[EMAIL PROTECTED]
> > > > Sent: Thursday, July 10, 2008 9:42 AM
> > > > To: paragasu
> > > > Cc: [EMAIL PROTECTED]
> > > > Subject: Re: [PHP] scalable web gallery
> > >
> > > ---8<--- snip
> > >
> > > >     And for the record, in the "olden days," there was a limit of
> > > > about 2048 files per directory, back when no one thought there
> > would
> > > > ever be a need for nearly that many files.  Then, with improved
> > > > filesystems, the limit was rumored to be another magic number:
> > 65535.
> > > > That depended on the operating system, filesystem, and the kernel.
> > I
> > > > think (but don't quote me on this) that BeOS had the 65535 limit.
> > > >
> > > >     Now, on an ext3 filesystem (we're not counting ReiserFS
> because
> > > > (1) I was never a fan, and (2) he might kill me if I say something
> > > > bad!  8^O) you're okay with hundreds of thousands of files per
> > > > directory.  ls'ing will be a bit of a pain in the ass, and if
> > you're
> > > > in Bash, you probably don't want to double-TAB the directory, but
> > all
> > > > in all, you'll be okay.
> > > >
> > > >     Still, I'd create 16 subdirectories under the images
> directory:
> > > > 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f.  Then name the file as an MD5
> hash
> > of
> > > > the image uploaded, and place it in the directory matching the
> > first
> > > > character of the new file name.
> > >
> > > Aren't directory structures in Windows (>2.x) and even DOS (>4.x)
> > built
> > > with B-Trees? I wouldn't figure there would be any kind of
> > > limit--excepting memory, of course--to how many files or
> > subdirectories
> > > can be linked to a single node.
> > >
> > > Been a while since I've played with those underlying data structures
> > we
> > > all take for granted, though, so maybe I'm way off base.
> > 
> > They may all be B-Trees but the storage mechanism often differs
> between
> > one filesystem and another. FAT16 and FAT32 both suffered from
> > limitations on the number of files that could exist in a directory.
> > Actually, I may be wrong about FAT32, but I do know for certain it had
> > massive slowdown if it hit some magic number.
> 
> tedd also sent me an e-mail that sparked a memory of mine... the
> b-trees, regardless of their efficiency, still assign each dir/file
> INode an identifying number. This number, obviously, can only get so
> large in the context of one b-tree object (i.e., a directory).
> 
> In spite of this mental exercise, I do *NOT* miss my Data Structures &
> Algorithms class. :)

Really? That along with distributed computing, and parallel computing
were my favourites... and here I am programming for the Web... I guess
it's distributed ;)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
At 12:31 AM -0400 7/11/08, Robert Cummings wrote:
On Thu, 2008-07-10 at 12:06 -0500, Boyd, Todd M. wrote:
 > tedd also sent me an e-mail that sparked a memory of mine... the
 b-trees, regardless of their efficiency, still assign each dir/file
 INode an identifying number. This number, obviously, can only get so
 large in the context of one b-tree object (i.e., a directory).

 In spite of this mental exercise, I do *NOT* miss my Data Structures &
 > Algorithms class. :)

Really? That along with distributed computing, and parallel computing
were my favourites... and here I am programming for the Web... I guess
it's distributed ;)

Cheers,
Rob.

Todd and Rob:

I understand.

But, I'm more inclined to agree with Rob, I actually *DO* miss Algorithms and such. There are great minds out there and it's nice to be able to touch their genius.

As for favorites, I liked digital filters, FFT, ray theory, computed surfaces, and all versions of AI. I even developed an algorithm to explain why migrating birds fly in a V formation. Some exciting Geek stuff.

But here I sit programming the web and following a client's instructions "I don't like that 'Buy Button' in blue, make it red." I feel like a 45 that's being used to swat flies. But hey, we all can't be born rich and most of us have to work for a living. At least I have work. :-)

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Thu, 2008-07-10 at 16:29 -0500, Philip Thompson wrote:
> On Jul 10, 2008, at 3:35 PM, Omar Noppe wrote:
> 
> > Is there any reason to pick a black background en white fonts in  
> > your editor (for example writability)?
> 
> I think a black background is much easier on the eyes....

And on the environment since the energy needed to sustain it is lower.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
On Thu, 2008-07-10 at 23:47 +0100, Colin Guthrie wrote:
> Dan Joseph wrote:
> > You could probably save even more if you didn't use those unneeded returns
> > also:
> > 
> > <?php function
> > aFunction($a,$b){if($a-$b<0){while($a+$b>0){if($c){$c++;}else{$c++;}}return
> > 'negative';}else{return 'possitive';}} ?>
> > 
> > I think that's still perfectly legible.
> 
> 
> And that looks like a suspiciously unnecessary " ?>" at the end 
> there.... I wonder what I'll spend my 24 bits on.... that could be 
> 1/1000 of a nipple in a grainy jpeg ;)

You only want to sharpen that image if the rest is easy on the eyes too.
Some things are better left grainy.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
On Jul 10, 2008, at 9:33 PM, Robert Cummings wrote:

On Thu, 2008-07-10 at 16:29 -0500, Philip Thompson wrote:
On Jul 10, 2008, at 3:35 PM, Omar Noppe wrote:

Is there any reason to pick a black background en white fonts in
your editor (for example writability)?

I think a black background is much easier on the eyes....

And on the environment since the energy needed to sustain it is lower.

Cheers,
Rob.

I find if I read stuff on a black background, I start seeing fuzzy streaks. I do use a light grey to edit in though.

Be cool to see screenshots of people's set-ups. The light grey is the only alteration I've ever made from BBedit's default settings.

-dg



--- End Message ---
--- Begin Message ---
On Thu, 2008-07-10 at 21:45 -0700, dg wrote:
>
> Be cool to see screenshots of people's set-ups.  The light grey is the  
> only alteration I've ever made from BBedit's default settings.

http://www.interjinn.com/bleh/snapshot.20080711.png

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---

On Jul 10, 2008, at 10:31 PM, Robert Cummings wrote:

http://www.interjinn.com/bleh/snapshot.20080711.png

very kewl. Maybe I'll ask Rich Siegel to pose shirtless for my BBedit background...

I'm used to line numbers along the side, especially given all my errors, how do you zoom in on them without seeing them there?

-dg


--- End Message ---
--- Begin Message ---
On Thu, 2008-07-10 at 22:49 -0700, dg wrote:
> On Jul 10, 2008, at 10:31 PM, Robert Cummings wrote:
> 
> > http://www.interjinn.com/bleh/snapshot.20080711.png
> 
> very kewl. Maybe I'll ask Rich Siegel to pose shirtless for my BBedit  
> background...
> 
> I'm used to line numbers along the side, especially given all my  
> errors, how do you zoom in on them without seeing them there?

CTRL+K L, input line number

Also the line the cursor is currently on is displayed at the top right
corner.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
On Fri, 2008-07-11 at 07:55 +0800, paragasu wrote:
> what  Robert suggest, is something exactly what the big-big photos
> gallery out there used
> to store their image. Distributing the image into many servers. But i
> am not very sure, how
> they store the image location information inside the database.
> 
> But i like the idea of using imageUId to determine where to store the image.
> I think, storing image in a bucket with 100 images each can make the image 
> more
> manageable..
> 
> thanks for that idea..

That physical location on the hard drive just needs to be a
configuration variable for the site. As long as all the servers use the
same physical path, then it's a no brainer.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
> As long as all the servers use the
> same physical path, then it's a no brainer.

well, for now, it might look no brainer. but in the future, i can move
the images to another
servers with few changes on dns configurations (i think so)..

On 7/11/08, Robert Cummings <[EMAIL PROTECTED]> wrote:
> On Fri, 2008-07-11 at 07:55 +0800, paragasu wrote:
>> what  Robert suggest, is something exactly what the big-big photos
>> gallery out there used
>> to store their image. Distributing the image into many servers. But i
>> am not very sure, how
>> they store the image location information inside the database.
>>
>> But i like the idea of using imageUId to determine where to store the
>> image.
>> I think, storing image in a bucket with 100 images each can make the image
>> more
>> manageable..
>>
>> thanks for that idea..
>
> That physical location on the hard drive just needs to be a
> configuration variable for the site. As long as all the servers use the
> same physical path, then it's a no brainer.
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
>

--- End Message ---
--- Begin Message ---
At 10:41 AM -0400 7/10/08, Daniel Brown wrote:
    Still, I'd create 16 subdirectories under the images directory:
0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f.  Then name the file as an MD5 hash of
the image uploaded, and place it in the directory matching the first
character of the new file name.

Why not use a hash table based upon the name of the file and distribute files that way?

You don't even need a directory until you actually need one -- then create one 'on-the-fly' and drop the file into it.

As such, it's easy to find the file again by simply hashing it's name -- you don't even need to store a path for the file, only the name of the file.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Thu, 2008-07-10 at 20:08 -0500, Luis Cordova wrote:
> I have been hunting for it for hours and seems like it is not there...
> It should but do you know how can I trace to which file is it pointing
> or what function? Is there anything close to debugging in php?

I hope you're not using Winblows:

    cd /path/to/web/tree
    grep -rn 'Please relogin again'

Cheers,
Rob.



> Encouragements,
> 
> On Thu, Jul 10, 2008 at 6:48 PM, Jim Lucas <[EMAIL PROTECTED]> wrote:
> > Luis Cordova wrote:
> >>
> >> A message "Session timeout! Please relogin again." appears after the
> >> session expires.
> >>
> >> I was looking in the php where can I:
> >>    1. modify the above text message
> >>    2. redirect after some seconds to another page.
> >> But I could not find anything in my code to do that.
> >>
> >> How can I do this? Any hints,
> >>
> >> Encouragements,
> >
> > #1 is in your PHP code and is unique to your php scripts.  It is not a
> > generic message that PHP generates.
> >
> > #2 is done client side with either Javascript or <meta .../> tag redirects
> >
> > --
> > Jim Lucas
> >
> >   "Some men are born to greatness, some achieve greatness,
> >       and some have greatness thrust upon them."
> >
> > Twelfth Night, Act II, Scene V
> >    by William Shakespeare
> >
> >
> 
> 
> 
> --
> 
>  Luis Cordova
> 
> 
> 
> -- 
> 
>  Luis Cordova
> 
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---


O/H dg ??????:
Hello,

I'd greatly appreciate some help with some problems I'm hitting.

I have a site set up on a dev server and it works fine.

In transferring it to the clients server, it's getting all weird.

When I first transferred created files, the owner was "joe". And they worked fine.

When I republished those files using fwrite, the owner changed to "httpd".

And includes and file_get_contents stopped working.

I tried changing the owner, but couldn't.
I changed include_path.


I turned on error reporting and got:

Warning: include(includes/common.php): failed to open stream: Inappropriate ioctl for device in /**/local/home/**/dev.**.net/alb**acl.php on line 5

Warning: file_get_contents(): SAFE MODE Restriction in effect. The script whose uid/gid is 398/398 is not allowed to access includes/lyrics_box_scripts.txt owned by uid/gid 191739/191739 in /**/local/home/**/dev.**.net/alb**acl.php on line 11


Thanks in advance for any assistance.

-dg


I think that a file stores a userid not the user so if for e.g. you have a user in your system that has id 1001 and you move this file preserving the rights to another computer the owner will become the user that has userid 1001 on the new system. In case there no user having the 1001 id then you will see just 1001 on the ownership when you "ls". In case you don't preserve the rights of the then I think that the user that copies/moves the files takes the ownership of the files. Since I believe that you are a unix user "man cp" on you system to see what is the switch for preserving rights (it is "-p" on Linux if I recall correctly) an make sure the same user gets the same id (usually happens for apache. On the other hand you may just simply change the ownership recursively like "chmod -R apache:apache <dir>" which is much easier.

--
Thodoris


--- End Message ---
--- Begin Message ---
Hi..

I recognize that this might be off base!! I've got an apache/vhosts question
that i'm grappling with. I've got a linux/apache system, and I'm trying to
get multiple vhosts to work. If this is an appropriate place, I'll provide
additional information on the issue.

I've looked/researched via the 'net but my issues are still with me!

Thanks




--- End Message ---
--- Begin Message ---
bruce wrote:
Hi..

I recognize that this might be off base!! I've got an apache/vhosts question
that i'm grappling with. I've got a linux/apache system, and I'm trying to
get multiple vhosts to work. If this is an appropriate place, I'll provide
additional information on the issue.

I've looked/researched via the 'net but my issues are still with me!

Thanks


You guess it, this isn't an appropriate place. What pieces are you struggling with as the Apache documentation works great for this stuff. I've got 6 hosts on a single server with no issues using the Apache documentation.

Wolf


--- End Message ---
--- Begin Message ---
On Fri, Jul 11, 2008 at 8:55 AM, bruce <[EMAIL PROTECTED]> wrote:
> Hi..
>
> I recognize that this might be off base!! I've got an apache/vhosts question
> that i'm grappling with. I've got a linux/apache system, and I'm trying to
> get multiple vhosts to work. If this is an appropriate place, I'll provide
> additional information on the issue.

    Check the archives and mailing lists at http://httpd.apache.org/.
To give you a pointer, though, you'll need to either do an include
into the httpd.conf file or modify that file itself to include a
NameVirtualHost setting and VirtualHost container.  It works fine.
I've worked with servers that have had hundreds of virtual hosts.

    The Apache folks are friendly, and don't bite *that* hard....

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

--- End Message ---
--- Begin Message ---
Hello everybody,

I hope you all have a nice day, mines not that good 'cause i have encountered a 
strange problem.

i have a few functions to work with dates. they are all very simple, a few 
lines of code.
this first one does just gives you the monday of the current week:

function get_monday($date) {
                
                $input_date = strtotime($date);
                $date_array = date_parse(date('r',$input_date));
                $get_sunday = 7 - $date_array['relative']['weekday'];
                
                $day_label = date("D, d.m.y",mktime(0, 0, 0, date("m")  , 
date("d")+$get_sunday, date("Y")));
                $new_day_label = strtotime($day_label);
                $monday = date("D, d.m.y",mktime(0, 0, 0, 
date("m",$new_day_label)  , date("d",$new_day_label)-6, 
date("Y",$new_day_label)));
                
                return($monday);
                
                }

now for testing purpose we say today is friday, 11.07.2008, this function 
returns correct Mon, 07.07.08.
now the problems lies in the second function or more in strtotime.
this second function just takes the inputed date and does some formating so it 
will fit into
the mysql db or query.

function get_mysql_date($date) {
                
                $old_date = strtotime($date);
                $new_date = date("Y-m-d",$old_date);

                return($new_date);
        }

But now the strange thing happening is, this function outputs '2008-07-14' 
which is monday of the next week.
now i think the problems lies somewhere in strtotime(), cause if i do this:

$dateForTable = $date_class->get_monday($today);
$dateTest =strtotime($dateForTable);
$dateTest2 =date('r',$yousuck);

it will also output 'Mon, 14 Jul 2008 07:07:08 +0200'.

i think strtotime() takes just the first part 'Mon' and looks what date the 
next monday is.
i'm realtivly new to php so any help solving this problem will be greatly 
appreciated.

thanks alot to all.

greetings from switzerland
------------------------ 
Fabian Frei 
[EMAIL PROTECTED] 
fon: 071-390 04 35 
mobile: 079-733 45 27 
------------------------

--- End Message ---
--- Begin Message ---
On Fri, Jul 11, 2008 at 9:03 AM, Fabian Frei <[EMAIL PROTECTED]>
wrote:

> Hello everybody,
>
> I hope you all have a nice day, mines not that good 'cause i have
> encountered a strange problem.
>
> i have a few functions to work with dates. they are all very simple, a few
> lines of code.
> this first one does just gives you the monday of the current week:
>
> function get_monday($date) {
>
>                $input_date = strtotime($date);
>                $date_array = date_parse(date('r',$input_date));
>                $get_sunday = 7 - $date_array['relative']['weekday'];
>
>                $day_label = date("D, d.m.y",mktime(0, 0, 0, date("m")  ,
> date("d")+$get_sunday, date("Y")));
>                $new_day_label = strtotime($day_label);
>                $monday = date("D, d.m.y",mktime(0, 0, 0,
> date("m",$new_day_label)  , date("d",$new_day_label)-6,
> date("Y",$new_day_label)));
>
>                return($monday);
>
>                }
>
> now for testing purpose we say today is friday, 11.07.2008, this function
> returns correct Mon, 07.07.08.
> now the problems lies in the second function or more in strtotime.
> this second function just takes the inputed date and does some formating so
> it will fit into
> the mysql db or query.
>
> function get_mysql_date($date) {
>
>                $old_date = strtotime($date);
>                $new_date = date("Y-m-d",$old_date);
>
>                return($new_date);
>        }
>
> But now the strange thing happening is, this function outputs '2008-07-14'
> which is monday of the next week.
> now i think the problems lies somewhere in strtotime(), cause if i do this:
>
> $dateForTable = $date_class->get_monday($today);
> $dateTest =strtotime($dateForTable);
> $dateTest2 =date('r',$yousuck);
>
> it will also output 'Mon, 14 Jul 2008 07:07:08 +0200'.
>
> i think strtotime() takes just the first part 'Mon' and looks what date the
> next monday is.
> i'm realtivly new to php so any help solving this problem will be greatly
> appreciated.
>
> thanks alot to all.
>
> greetings from switzerland
> ------------------------
> Fabian Frei
> [EMAIL PROTECTED]
> fon: 071-390 04 35
> mobile: 079-733 45 27
> ------------------------
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
function get_monday()
{
  return date("Y-m-d", strtotime("last monday"));
}

function get_mysql_date()
{
  return date("Y-m-d");
}

would seem to be much simpler

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
<?php

/*

I have a question here regarding object orientation in PHP and any other
language.

Let's start with some hypothetical code:

*/

// <--- 1st CLASS

class ParkingLot {

var size; // size in sq feet

var max_number_of_cars; // how many cars there is space for

function __construct($size, $max_cars) {

$this->size = $size; $this->max_number_of_cars = $max_cars;

}

};

cpark = new ParkingLot(50000, 17);

// <--- 2nd CLASS

class ParkingSpace extends ParkingLot {

var ps_ID; // ID of the parking space ( 1 .. max_number_of_cars )

var occupied_by; // ID of the car on the parking space

var st_time; // Unix time stamp set when the car parks

function __construct($car, $id) {

$this->st_time = time();

$this->occupied_by = $car;

$this->ps_ID = $id;

}

};

/*

OK, so i got a parking lot class and its subclass parking space.

Now the question:

I want a list of occupied parking spaces, where do I put that? One might put
it into the ParkingLot Class, but wouldn't that be a recursion (a child
instance in the parent class)?

*/

$occ_parking_spaces = array();

$occ_parking_spaces[] =& new ParkingSpace('Joes Car', 8);

$occ_parking_spaces[] =& new ParkingSpace('My Prshe', 17);

$occ_parking_spaces[] =& new ParkingSpace('Toms Caddy', 4);

/*

After a while a method to print all occupied spaces is necessary. Correct me
if I'm wrong, but I usually add it to the ParkingLot class.

class ParkingLot {

// previous code ...

var $occ_parking_spaces = array();

function print_occ_spaces() {

var_dump($this->occ_parking_spaces)

}

};

What bothers me here is that I'm actually having a list of child classes in
the parent class, is there a better/correct way to do this?

I hope I made myself clear.

Greetz,

Yeti

*/

?>

--- End Message ---
--- Begin Message ---
On Fri, 2008-07-11 at 18:03 +0200, Yeti wrote:
> <?php
> 
> /*
> 
> I have a question here regarding object orientation in PHP and any other
> language.
> 
> Let's start with some hypothetical code:
> 
> */
> 
> // <--- 1st CLASS
> 
> class ParkingLot {
> 
> var size; // size in sq feet
> 
> var max_number_of_cars; // how many cars there is space for
> 
> function __construct($size, $max_cars) {
> 
> $this->size = $size; $this->max_number_of_cars = $max_cars;
> 
> }
> 
> };
> 
> cpark = new ParkingLot(50000, 17);
> 
> // <--- 2nd CLASS
> 
> class ParkingSpace extends ParkingLot {

Here's the point of your comfusion. ParkingSpace is not really a
ParkingLot is it? I mean you could say a parking lot having a single
parking space qualifies, but not really. I see you problem being similar
to apples versus apple tree. You wouldn't do the following (would you?):

<?php

class AppleTree
{
}

class Apple extends AppleTree
{
}

?>

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---

Object-oriented programming, with it's "class" and "object" approach, is meant to model real life more closely than functional programming.

In, a "parking space" is physically inside a "parking lot", but a parking space is not a subclass of a parking lot. It's not a variation or mini parking lot. It's an entirely different entity. A parking lot consists of parking spaces, but a parking space is its own thing.

In other words, don't extend ParkingSpace from ParkingLot. They should be separate classes entirely.

As for the recursion... no, that won't be a problem. Each ParkingSpace you're instantiating is a separate instance, and won't be related to the parent ParkingLot in anyway way internally.

<?php

class ParkingSpace {
    var $size;
    var $num_spaces;
    var $spaces = array();
}

class ParkingSpace {
    var $ps_ID;
    var $occupied_by;
    var $st_time;
}

?>

In the above class definition, simply populate the $spaces array with instances of the ParkingSpace class.

~Ted




On 11-Jul-08, at 9:03 AM, Yeti wrote:

<?php

/*

I have a question here regarding object orientation in PHP and any other
language.

Let's start with some hypothetical code:

*/

// <--- 1st CLASS

class ParkingLot {

var size; // size in sq feet

var max_number_of_cars; // how many cars there is space for

function __construct($size, $max_cars) {

$this->size = $size; $this->max_number_of_cars = $max_cars;

}

};

cpark = new ParkingLot(50000, 17);

// <--- 2nd CLASS

class ParkingSpace extends ParkingLot {

var ps_ID; // ID of the parking space ( 1 .. max_number_of_cars )

var occupied_by; // ID of the car on the parking space

var st_time; // Unix time stamp set when the car parks

function __construct($car, $id) {

$this->st_time = time();

$this->occupied_by = $car;

$this->ps_ID = $id;

}

};

/*

OK, so i got a parking lot class and its subclass parking space.

Now the question:

I want a list of occupied parking spaces, where do I put that? One might put it into the ParkingLot Class, but wouldn't that be a recursion (a child
instance in the parent class)?

*/

$occ_parking_spaces = array();

$occ_parking_spaces[] =& new ParkingSpace('Joes Car', 8);

$occ_parking_spaces[] =& new ParkingSpace('My Prshe', 17);

$occ_parking_spaces[] =& new ParkingSpace('Toms Caddy', 4);

/*

After a while a method to print all occupied spaces is necessary. Correct me
if I'm wrong, but I usually add it to the ParkingLot class.

class ParkingLot {

// previous code ...

var $occ_parking_spaces = array();

function print_occ_spaces() {

var_dump($this->occ_parking_spaces)

}

};

What bothers me here is that I'm actually having a list of child classes in
the parent class, is there a better/correct way to do this?

I hope I made myself clear.

Greetz,

Yeti

*/

?>


--- End Message ---
--- Begin Message ---
Corrected code example:

(too early in the morning to think)

<?php

class ParkingLot {
   var $size;
   var $num_spaces;
   var $spaces = array();
}

class ParkingSpace {
   var $ps_ID;
   var $occupied_by;
   var $st_time;
}

?>

In the above class definition, simply populate the $spaces array with instances of the ParkingSpace class.

~Ted

--- End Message ---
--- Begin Message ---
At 7:20 PM +0100 7/10/08, Alex Chamberlain wrote:
I need to send a header('Location:....') and send some data along with it -
how would I do this??

Thanks,

Alex

Alext:

Or you could just:

   ob_clean();
   include('theNextScript.php');
   exit();

The variable in your parent script will be "passed" to the next script.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Ahh, but they are on different webservers....

At the moment, I am just using a query string. How long is the limit of the
query string??

Alex

> -----Original Message-----
> From: tedd [mailto:[EMAIL PROTECTED]
> Sent: 11 July 2008 17:12
> To: Alex Chamberlain; PHP General list
> Subject: Re: [PHP] Relocating and POSTing
> 
> At 7:20 PM +0100 7/10/08, Alex Chamberlain wrote:
> >I need to send a header('Location:....') and send some data along with
> it -
> >how would I do this??
> >
> >Thanks,
> >
> >Alex
> 
> Alext:
> 
> Or you could just:
> 
>     ob_clean();
>     include('theNextScript.php');
>     exit();
> 
> The variable in your parent script will be "passed" to the next script.
> 
> Cheers,
> 
> tedd
> 
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com
> Version: 8.0.138 / Virus Database: 270.4.7/1546 - Release Date:
> 11/07/2008 06:47

No virus found in this outgoing message. Scanned by AVG Free 8.0
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.4.7/1546 - Release Date: 11/07/2008
06:47

No virus found in this outgoing message. Scanned by AVG Free 8.0
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.4.7/1546 - Release Date: 11/07/2008
06:47


--- End Message ---
--- Begin Message ---
On Fri, Jul 11, 2008 at 12:26 PM, Alex Chamberlain
<[EMAIL PROTECTED]> wrote:
> Ahh, but they are on different webservers....

    That's why I mentioned cURL at the very beginning, if it had to be
done as a POST request.

> At the moment, I am just using a query string. How long is the limit of the
> query string??

    There is no official limit in the protocol, but you may want to
check out Section 3.2.1 of RFC 2068 for more on that.

    The limits are in what the client is capable of sending, and what
the server is capable of receiving.  A quick S of TFW should give you
the information you need regarding PHP and the remote server's
configuration.

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

--- End Message ---

Reply via email to