OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
php-general Digest 12 Mar 2008 20:31:02 -0000 Issue 5344

php-general-digest-helplists.php.net
Date: Wed Mar 12 2008 - 15:31:02 CDT


php-general Digest 12 Mar 2008 20:31:02 -0000 Issue 5344

Topics (messages 271333 through 271434):

Re: PHP & Ajax progress bar
        271333 by: Mr Webber
        271334 by: Thijs Lensselink
        271337 by: Shelley
        271338 by: Thijs Lensselink
        271365 by: Philip Thompson
        271371 by: Thijs Lensselink
        271378 by: Philip Thompson
        271381 by: Daniel Brown
        271384 by: Thijs Lensselink

Parameter
        271335 by: John Comerford

Re: Know a JS list serve
        271336 by: Frank Arensmeier
        271353 by: Jason Pruim

Comparing files
        271339 by: mathieu leddet
        271340 by: Thijs Lensselink
        271341 by: Stut
        271342 by: Aschwin Wesselius
        271343 by: Edward Kay
        271344 by: mathieu leddet
        271345 by: Per Jessen
        271346 by: Andrés Robinet
        271354 by: Edward Kay
        271357 by: Thijs Lensselink

setcookie
        271347 by: Tim Daff
        271348 by: Jean-Christophe Roux
        271349 by: Hiep Nguyen
        271350 by: Shiplu
        271351 by: Zareef Ahmed
        271352 by: Tim Daff
        271355 by: Richard Heyes
        271356 by: Wolf
        271358 by: Ray Hauge

What's wrong the __autoload()?
        271359 by: Gustavo Narea
        271361 by: Richard Heyes
        271386 by: Greg Donald
        271390 by: Robert Cummings
        271395 by: Greg Donald
        271396 by: Richard Heyes
        271398 by: Greg Donald
        271399 by: Eric Butera
        271400 by: Richard Heyes
        271402 by: Greg Donald
        271403 by: Zoltán Németh
        271404 by: Richard Heyes
        271405 by: Greg Donald
        271406 by: Robert Cummings
        271407 by: Robert Cummings
        271408 by: Greg Donald
        271409 by: Greg Donald
        271410 by: Zoltán Németh
        271411 by: Wolf
        271412 by: Robert Cummings
        271413 by: Stut
        271414 by: Greg Donald
        271418 by: Zoltán Németh
        271419 by: Andrés Robinet
        271420 by: Stephane Ulysse
        271421 by: Zoltán Németh
        271422 by: Nathan Nobbe
        271423 by: Greg Donald
        271424 by: Robert Cummings
        271425 by: Andrés Robinet
        271426 by: Zoltán Németh
        271427 by: Nathan Nobbe
        271428 by: Greg Donald
        271429 by: Aschwin Wesselius
        271430 by: Nathan Nobbe
        271431 by: Greg Donald
        271434 by: Andrés Robinet

best practices in error handling in PHP
        271360 by: It Maq
        271363 by: Richard Heyes
        271364 by: Christoph Boget
        271366 by: It Maq
        271368 by: Zoltán Németh
        271369 by: It Maq

mail function and headers
        271362 by: Alain Roger
        271367 by: Daniel Brown
        271380 by: spacemarc
        271387 by: Alain Roger
        271388 by: Alain Roger
        271391 by: Alain Roger

Re: Timezone management
        271370 by: Jim Lucas
        271376 by: Daniel Brown

A Quick Reminder....
        271372 by: Daniel Brown
        271373 by: Daniel Brown
        271374 by: Daniel Brown
        271375 by: Daniel Brown
        271377 by: TG
        271379 by: Daniel Brown
        271382 by: Aschwin Wesselius
        271383 by: Jason Pruim
        271385 by: Wolf
        271392 by: Per Jessen
        271393 by: Andrés Robinet
        271394 by: TG
        271397 by: TG
        271401 by: Ray Hauge

Re: strtotime( 'last Sunday' ) and republicans
        271389 by: Greg Donald

Re: Storing values between multiple page forms
        271415 by: Jim Lucas
        271416 by: Daniel Brown

PHP CLI neat errors!
        271417 by: Steve Finkelstein

Frameworks
        271432 by: Aschwin Wesselius
        271433 by: Greg Donald

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


I haven't' tried this yet ... so I would appreciate your feedback.

-----Original Message-----
From: Thijs Lensselink [mailto:devlenss.nl]
Sent: Wednesday, March 12, 2008 4:28 AM
To: php-generallists.php.net
Subject: Re: [PHP] PHP & Ajax progress bar

Quoting Shelley <myphplistgmail.com>:

> Hi all,
>
> I'm searching some file upload progress bar code.
> But no good result was found. :(
> So is there anybody please be kind enough to show some code here?
>
> Great thanks.
>
> --
> Regard,
> Shelley (http://phparch.cn)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

You can try searching the archives. Rasmus had an example a long time ago.
Although it requires APC to be installed. Maybe it's interesting.

Found it:
Example : http://progphp.com/upload.php
Source : http://progphp.com/upload.phps

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


Quoting Mr Webber <captain_webberhotmail.com>:

> I haven't' tried this yet ... so I would appreciate your feedback.
>
> -----Original Message-----
> From: Thijs Lensselink [mailto:devlenss.nl]
> Sent: Wednesday, March 12, 2008 4:28 AM
> To: php-generallists.php.net
> Subject: Re: [PHP] PHP & Ajax progress bar
>
> Quoting Shelley <myphplistgmail.com>:
>
>> Hi all,
>>
>> I'm searching some file upload progress bar code.
>> But no good result was found. :(
>> So is there anybody please be kind enough to show some code here?
>>
>> Great thanks.
>>
>> --
>> Regard,
>> Shelley (http://phparch.cn)
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>
> You can try searching the archives. Rasmus had an example a long time ago.
> Although it requires APC to be installed. Maybe it's interesting.
>
> Found it:
> Example : http://progphp.com/upload.php
> Source : http://progphp.com/upload.phps
>
> --

Pls don't top post.

If you want to know if it works. Go ahead!
Copy paste the code and give it a try.

attached mail follows:


Thijs Lensselink 写é“:
> Quoting Mr Webber <captain_webberhotmail.com>:
>
>> I haven't' tried this yet ... so I would appreciate your feedback.
>>
>> -----Original Message-----
>> From: Thijs Lensselink [mailto:devlenss.nl]
>> Sent: Wednesday, March 12, 2008 4:28 AM
>> To: php-generallists.php.net
>> Subject: Re: [PHP] PHP & Ajax progress bar
>>
>> Quoting Shelley <myphplistgmail.com>:
>>
>>> Hi all,
>>>
>>> I'm searching some file upload progress bar code.
>>> But no good result was found. :(
>>> So is there anybody please be kind enough to show some code here?
>>>
>>> Great thanks.
>>>
>>> --
>>> Regard,
>>> Shelley (http://phparch.cn)
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>> You can try searching the archives. Rasmus had an example a long time
>> ago.
>> Although it requires APC to be installed. Maybe it's interesting.
>>
>> Found it:
>> Example : http://progphp.com/upload.php
>> Source : http://progphp.com/upload.phps
>>
>> --
>
> Pls don't top post.
>
> If you want to know if it works. Go ahead!
> Copy paste the code and give it a try.
>
>
I don't think it works.

I tried.
The screen always said 0%, 0 of 0 byte until the file is uploaded.
Is that what you mean progress bar?

--
Regards,
Shelley (http://phparch.cn)

attached mail follows:


Quoting Shelley <myphplistgmail.com>:

> Thijs Lensselink 写é“:
>> Quoting Mr Webber <captain_webberhotmail.com>:
>>
>>> I haven't' tried this yet ... so I would appreciate your feedback.
>>>
>>> -----Original Message-----
>>> From: Thijs Lensselink [mailto:devlenss.nl]
>>> Sent: Wednesday, March 12, 2008 4:28 AM
>>> To: php-generallists.php.net
>>> Subject: Re: [PHP] PHP & Ajax progress bar
>>>
>>> Quoting Shelley <myphplistgmail.com>:
>>>
>>>> Hi all,
>>>>
>>>> I'm searching some file upload progress bar code.
>>>> But no good result was found. :(
>>>> So is there anybody please be kind enough to show some code here?
>>>>
>>>> Great thanks.
>>>>
>>>> --
>>>> Regard,
>>>> Shelley (http://phparch.cn)
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>> You can try searching the archives. Rasmus had an example a long time ago.
>>> Although it requires APC to be installed. Maybe it's interesting.
>>>
>>> Found it:
>>> Example : http://progphp.com/upload.php
>>> Source : http://progphp.com/upload.phps
>>>
>>> --
>>
>> Pls don't top post.
>>
>> If you want to know if it works. Go ahead!
>> Copy paste the code and give it a try.
>>
>>
> I don't think it works.
>
> I tried.
> The screen always said 0%, 0 of 0 byte until the file is uploaded.
> Is that what you mean progress bar?
>
> --
> Regards,
> Shelley (http://phparch.cn)
>

Do you have all the yui files? and APC enabled?
I tried it some time ago and it worked. But i did have to set

apc.rfc1867 = on

in php.ini to make it work. Forgot to mention that one.

attached mail follows:


On Mar 12, 2008, at 5:02 AM, Thijs Lensselink wrote:

>> Thijs Lensselink 写é“:

How do you pronounce your name?

attached mail follows:


Quoting Philip Thompson <philthathrilgmail.com>:

> On Mar 12, 2008, at 5:02 AM, Thijs Lensselink wrote:
>
>>> Thijs Lensselink 写é“:
>
> How do you pronounce your name?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Well.. how to explain this one...

thijs : T + [ice]

That's the best i can do :)

attached mail follows:


On Mar 12, 2008, at 9:52 AM, Thijs Lensselink wrote:

> Quoting Philip Thompson <philthathrilgmail.com>:
>
>> On Mar 12, 2008, at 5:02 AM, Thijs Lensselink wrote:
>>
>>>> Thijs Lensselink 写é“:
>>
>> How do you pronounce your name?
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>
> Well.. how to explain this one...
>
> thijs : T + [ice]
>
> That's the best i can do :)

Which is different than the famous rapper/actor...

hijs-t : [ice] + T

Hehehe =D

attached mail follows:


On Wed, Mar 12, 2008 at 11:03 AM, Philip Thompson
<philthathrilgmail.com> wrote:
> On Mar 12, 2008, at 9:52 AM, Thijs Lensselink wrote:
> > Quoting Philip Thompson <philthathrilgmail.com>:
> >>
> >> How do you pronounce your name?
> >
> > Well.. how to explain this one...
> >
> > thijs : T + [ice]
> >
>
> Which is different than the famous rapper/actor...
>
> hijs-t : [ice] + T
>

    HA!

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


Quoting Daniel Brown <parasanegmail.com>:

> On Wed, Mar 12, 2008 at 11:03 AM, Philip Thompson
> <philthathrilgmail.com> wrote:
>> On Mar 12, 2008, at 9:52 AM, Thijs Lensselink wrote:
>> > Quoting Philip Thompson <philthathrilgmail.com>:
>> >>
>> >> How do you pronounce your name?
>> >
>> > Well.. how to explain this one...
>> >
>> > thijs : T + [ice]
>> >
>>
>> Which is different than the famous rapper/actor...
>>
>> hijs-t : [ice] + T
>>
>
> HA!
>
> --
> </Dan>
>
> Daniel P. Brown
> Senior Unix Geek
> <? while(1) { $me = $mind--; sleep(86400); } ?>
>

Same reaction here!

attached mail follows:


Hi Folks,

I am thinking of putting together a class to handle passing parameters
to a class. Basically when you define a class you would define your
class to extend the parameter class.
The parameter class would be JSON compliant so in the end when you call
a class it you could pass the parameters as a JSON string.
(rough) eg.

myClass("label:test,title:this is text");

the parameter class would allow you to do something like:
 echo myClass->get("label");

The advantages are:
- You don't have to have a declaration for every variable used within
your class
- I could make the parameter class case independent (I know I need a
flame suit for this but case dependency get on my nerves)
- I can wrap a lot of functionality into the parameter class, stuff like
'ifNotNull("label") .......'

So far disadvantages are:
- Eclipse etc. has code completion, which means all the parameters you
pass to a function can be presented to the developer as part of "code
completion"

I'd like to know:
- Have any of you guys already done something like I am talking about.
- As developers do you reckon losing code completion is worth the
advantages of a parameter class
- Have I overlooked something major ?

Let me know what you think,
  JC

attached mail follows:


11 mar 2008 kl. 22.39 skrev Skip Evans:

> Hey all,
>
> I've been Googling trying to find a JavaScript list serve to post a
> question to, but have been, embarrassingly, unable to find one.
>
> Anyone on one they'd recommend or know of one?
>
> Thanks
>
> *sigh*
>
>
Evolt has a rather good list (not too much traffic, but still ...)

http://lists.evolt.org/mailman/listinfo/javascript

//frank

attached mail follows:


On Mar 12, 2008, at 4:14 AM, Frank Arensmeier wrote:

> 11 mar 2008 kl. 22.39 skrev Skip Evans:
>
>> Hey all,
>>
>> I've been Googling trying to find a JavaScript list serve to post a
>> question to, but have been, embarrassingly, unable to find one.
>>
>> Anyone on one they'd recommend or know of one?
>>
>> Thanks
>>
>> *sigh*
>>
>>
> Evolt has a rather good list (not too much traffic, but still ...)
>
> http://lists.evolt.org/mailman/listinfo/javascript

Also, Apple has a javascript list... It's the Dashboard Developers
list... But the Widgets are nothing more then HTML/CSS/XML/Javascript/
PHP type webpages designed for a specific use... Lots of knowledgeable
javascript people there...

http://lists.apple.com/mailman/listinfo/dashboard-dev/
--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruimraoset.com

attached mail follows:


Hi all,

I have a simple question : how can I ensure that 2 files are identical ?

How about this ?

--------8<------------------------------------------------------

function files_identical($path1, $path2) {
        
  return (file_get_contents($path1) == file_get_contents($path2));

}

--------8<------------------------------------------------------

Note that I would like to compare any type of files (text and binary).

Thanks for any help,

--
Mathieu

attached mail follows:


Quoting mathieu leddet <mathieu.leddetmobilescope.com>:

> Hi all,
>
> I have a simple question : how can I ensure that 2 files are identical ?
>
> How about this ?
>
> --------8<------------------------------------------------------
>
> function files_identical($path1, $path2) {
>
> return (file_get_contents($path1) == file_get_contents($path2));
>
> }
>
> --------8<------------------------------------------------------
>
> Note that I would like to compare any type of files (text and binary).
>
> Thanks for any help,
>
>
> --
> Mathieu
>

You could use "md5_file" for this. Something like:

function files_identical($path1, $path2) {

   return (md5_file($path1) == md5_file($path2));

}

attached mail follows:


mathieu leddet wrote:
> I have a simple question : how can I ensure that 2 files are identical ?
>
> How about this ?
>
> --------8<------------------------------------------------------
>
> function files_identical($path1, $path2) {
>
> return (file_get_contents($path1) == file_get_contents($path2));
>
> }
>
> --------8<------------------------------------------------------
>
> Note that I would like to compare any type of files (text and binary).

http://php.net/md5_file

-Stut

--
http://stut.net/

attached mail follows:


mathieu leddet wrote:
> Hi all,
>
> I have a simple question : how can I ensure that 2 files are identical ?
>
> How about this ?
>
> --------8<------------------------------------------------------
>
> function files_identical($path1, $path2) {
>
> return (file_get_contents($path1) == file_get_contents($path2));
>
> }
I would say, use a md5 checksum on both files:

function files_identical($path1, $path2) {
        
  return (md5(file_get_contents($path1)) === md5(file_get_contents($path2)));

}

--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other....'/

attached mail follows:


> -----Original Message-----
> From: mathieu leddet [mailto:mathieu.leddetmobilescope.com]
> Sent: 12 March 2008 11:04
> To: php-generallists.php.net
> Subject: [PHP] Comparing files
>
>
> Hi all,
>
> I have a simple question : how can I ensure that 2 files are identical ?
>
> How about this ?
>
> --------8<------------------------------------------------------
>
> function files_identical($path1, $path2) {
>
> return (file_get_contents($path1) == file_get_contents($path2));
>
> }
>
> --------8<------------------------------------------------------
>
> Note that I would like to compare any type of files (text and binary).
>
> Thanks for any help,
>

Depending upon the size of the files, I would expect it would be quicker to
compare a hash of each file.

Edward

attached mail follows:


Yes!

Thanks a lot, "md5_file" suits perfectly well my needs.
I've read that 'exec'ing the md5 command is faster... I'll see when performance on large files will become an issue.

Thanks again,

--
Mathieu

-----Message d'origine-----
De : Thijs Lensselink [mailto:devlenss.nl]
Envoyé : Wednesday, March 12, 2008 12:09 PM
À : php-generallists.php.net
Objet : Re: [PHP] Comparing files

Quoting mathieu leddet <mathieu.leddetmobilescope.com>:

> Hi all,
>
> I have a simple question : how can I ensure that 2 files are identical ?
>
> How about this ?
>
> --------8<------------------------------------------------------
>
> function files_identical($path1, $path2) {
>
> return (file_get_contents($path1) == file_get_contents($path2));
>
> }
>
> --------8<------------------------------------------------------
>
> Note that I would like to compare any type of files (text and binary).
>
> Thanks for any help,
>
>
> --
> Mathieu
>

You could use "md5_file" for this. Something like:

function files_identical($path1, $path2) {

   return (md5_file($path1) == md5_file($path2));

}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


mathieu leddet wrote:

> Yes!
>
> Thanks a lot, "md5_file" suits perfectly well my needs.
> I've read that 'exec'ing the md5 command is faster... I'll see when
> performance on large files will become an issue.
>

Doing a diff on the files would make absolutely certain - an md5
checksum is not.

/Per Jessen, Zürich

attached mail follows:


> -----Original Message-----
> From: Edward Kay [mailto:edwardlabhut.com]
> Sent: Wednesday, March 12, 2008 7:13 AM
> To: mathieu leddet; php-generallists.php.net
> Subject: RE: [PHP] Comparing files
>
>
>
> > -----Original Message-----
> > From: mathieu leddet [mailto:mathieu.leddetmobilescope.com]
> > Sent: 12 March 2008 11:04
> > To: php-generallists.php.net
> > Subject: [PHP] Comparing files
> >
> >
> > Hi all,
> >
> > I have a simple question : how can I ensure that 2 files are identical ?
> >
> > How about this ?
> >
> > --------8<------------------------------------------------------
> >
> > function files_identical($path1, $path2) {
> >
> > return (file_get_contents($path1) == file_get_contents($path2));
> >
> > }
> >
> > --------8<------------------------------------------------------
> >
> > Note that I would like to compare any type of files (text and binary).
> >
> > Thanks for any help,
> >
>
> Depending upon the size of the files, I would expect it would be quicker to
> compare a hash of each file.
>
> Edward
>

I don't understand how comparing hashes can be faster than comparing contents,
except for big files for which you will likely hit the memory limit first and
for files who only differ from each other at the very end of them, so the
comparison will only be halted then. If the file sizes vary too much, however, a
mixed strategy would be the winner; and certainly, you will want to store path
names and calculated hashes in a database of some kind to save yourself from
hogging the server each time (yeah, CPU and RAM are cheap, but not unlimited
resources).

Comparing hashes means that a hash must be calculated for files A and B and the
related overhead will increase according to the file size (right or wrong?).
Comparing the file contents will have an associated overhead for buffering and
moving the file contents into memory, and it's also a linear operation (strings
are compared byte to byte till there's a difference). So... why not doing the
following?

1 - Compare file sizes (this is just a property stored in the file system
structures, right?). If sizes are different, the files are different. Otherwise
move to step 2.
2 - If the file sizes are smaller than certain size (up to you to find the
optimal file size), just compare contents through, say, file_get_contents.
Otherwise move to step 3.
3 - Grab some random bytes at the beginning, at the middle and at the end of
both files and compare them. If they are different, the files are different.
Otherwise move to step 4.
4 - If you reach this point, you are doomed. You have 2 big files that you must
compare and they are apparently equal so far. Comparing contents will be over
killing if at all possible, so you will want to generate hashes and compare
them. Run md5_file on both files (it would be great if you have, say, file A's
hash already calculated and stored in a DB or data file) and compare results.

It is always up to what kind of files you are dealing with, if the files are
often different only at the end of the stream, you may want to skip step 2. But
this is what I would generally do.

By the way, md5 is a great hashing function, but it is not bullet-proof,
collisions may happen (though it's much better than crc32, for example). So, you
may also think of how critical is to you to have some false positives (some
files that are considered equal by md5_file and they are not) and probably use
some diff-like solution instead of md5_file. Anyway, having compared sizes and
random bytes (steps 1 through 3), it's very likely that md5_file will catch it
if two files are different in just a few bytes.

Regards,

Rob

Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 |
TEL 954-607-4207 | FAX 954-337-2695 |
Email: infobestplace.net  | MSN Chat: bestbestplace.net  |  SKYPE: bestplace |
 Web: bestplace.biz  | Web: seo-diy.com

attached mail follows:


> -----Original Message-----
> From: Andrés Robinet [mailto:agrobinetbestplace.biz]
> Sent: 12 March 2008 12:33
> To: 'Edward Kay'; 'mathieu leddet'; php-generallists.php.net
> Subject: RE: [PHP] Comparing files
>
>
> > -----Original Message-----
> > From: Edward Kay [mailto:edwardlabhut.com]
> > Sent: Wednesday, March 12, 2008 7:13 AM
> > To: mathieu leddet; php-generallists.php.net
> > Subject: RE: [PHP] Comparing files
> >
> >
> >
> > > -----Original Message-----
> > > From: mathieu leddet [mailto:mathieu.leddetmobilescope.com]
> > > Sent: 12 March 2008 11:04
> > > To: php-generallists.php.net
> > > Subject: [PHP] Comparing files
> > >
> > >
> > > Hi all,
> > >
> > > I have a simple question : how can I ensure that 2 files are
> identical ?
> > >
> > > How about this ?
> > >
> > > --------8<------------------------------------------------------
> > >
> > > function files_identical($path1, $path2) {
> > >
> > > return (file_get_contents($path1) == file_get_contents($path2));
> > >
> > > }
> > >
> > > --------8<------------------------------------------------------
> > >
> > > Note that I would like to compare any type of files (text and binary).
> > >
> > > Thanks for any help,
> > >
> >
> > Depending upon the size of the files, I would expect it would
> be quicker to
> > compare a hash of each file.
> >
> > Edward
> >
>
> I don't understand how comparing hashes can be faster than
> comparing contents,
> except for big files for which you will likely hit the memory
> limit first and
> for files who only differ from each other at the very end of them, so the
> comparison will only be halted then. If the file sizes vary too
> much, however, a
> mixed strategy would be the winner; and certainly, you will want
> to store path
> names and calculated hashes in a database of some kind to save
> yourself from
> hogging the server each time (yeah, CPU and RAM are cheap, but
> not unlimited
> resources).
>
> Comparing hashes means that a hash must be calculated for files A
> and B and the
> related overhead will increase according to the file size (right
> or wrong?).
> Comparing the file contents will have an associated overhead for
> buffering and
> moving the file contents into memory, and it's also a linear
> operation (strings
> are compared byte to byte till there's a difference). So... why
> not doing the
> following?
>
> 1 - Compare file sizes (this is just a property stored in the file system
> structures, right?). If sizes are different, the files are
> different. Otherwise
> move to step 2.
> 2 - If the file sizes are smaller than certain size (up to you to find the
> optimal file size), just compare contents through, say, file_get_contents.
> Otherwise move to step 3.
> 3 - Grab some random bytes at the beginning, at the middle and at
> the end of
> both files and compare them. If they are different, the files are
> different.
> Otherwise move to step 4.
> 4 - If you reach this point, you are doomed. You have 2 big files
> that you must
> compare and they are apparently equal so far. Comparing contents
> will be over
> killing if at all possible, so you will want to generate hashes
> and compare
> them. Run md5_file on both files (it would be great if you have,
> say, file A's
> hash already calculated and stored in a DB or data file) and
> compare results.
>
> It is always up to what kind of files you are dealing with, if
> the files are
> often different only at the end of the stream, you may want to
> skip step 2. But
> this is what I would generally do.
>
> By the way, md5 is a great hashing function, but it is not bullet-proof,
> collisions may happen (though it's much better than crc32, for
> example). So, you
> may also think of how critical is to you to have some false
> positives (some
> files that are considered equal by md5_file and they are not) and
> probably use
> some diff-like solution instead of md5_file. Anyway, having
> compared sizes and
> random bytes (steps 1 through 3), it's very likely that md5_file
> will catch it
> if two files are different in just a few bytes.
>

Agreed. In by first reply, I meant that hashes would likely be quicker/more
memory friendly when handling larger files, but this is just a hunch - I
haven't benchmarked anything. It was really meant to give the OP other
possibilities to look into.

Edward

attached mail follows:


Quoting Andrés Robinet <agrobinetbestplace.biz>:

>> -----Original Message-----
>> From: Edward Kay [mailto:edwardlabhut.com]
>> Sent: Wednesday, March 12, 2008 7:13 AM
>> To: mathieu leddet; php-generallists.php.net
>> Subject: RE: [PHP] Comparing files
>>
>>
>>
>> > -----Original Message-----
>> > From: mathieu leddet [mailto:mathieu.leddetmobilescope.com]
>> > Sent: 12 March 2008 11:04
>> > To: php-generallists.php.net
>> > Subject: [PHP] Comparing files
>> >
>> >
>> > Hi all,
>> >
>> > I have a simple question : how can I ensure that 2 files are identical ?
>> >
>> > How about this ?
>> >
>> > --------8<------------------------------------------------------
>> >
>> > function files_identical($path1, $path2) {
>> >
>> > return (file_get_contents($path1) == file_get_contents($path2));
>> >
>> > }
>> >
>> > --------8<------------------------------------------------------
>> >
>> > Note that I would like to compare any type of files (text and binary).
>> >
>> > Thanks for any help,
>> >
>>
>> Depending upon the size of the files, I would expect it would be quicker to
>> compare a hash of each file.
>>
>> Edward
>>
>
> I don't understand how comparing hashes can be faster than comparing
> contents,
> except for big files for which you will likely hit the memory limit first and
> for files who only differ from each other at the very end of them, so the
> comparison will only be halted then. If the file sizes vary too
> much, however, a
> mixed strategy would be the winner; and certainly, you will want to
> store path
> names and calculated hashes in a database of some kind to save yourself from
> hogging the server each time (yeah, CPU and RAM are cheap, but not unlimited
> resources).

I must agree that a mixed solution would be best here.

> Comparing hashes means that a hash must be calculated for files A
> and B and the
> related overhead will increase according to the file size (right or wrong?).
> Comparing the file contents will have an associated overhead for
> buffering and
> moving the file contents into memory, and it's also a linear
> operation (strings
> are compared byte to byte till there's a difference). So... why not doing the
> following?
>
> 1 - Compare file sizes (this is just a property stored in the file system
> structures, right?). If sizes are different, the files are
> different. Otherwise
> move to step 2.

I like this idea. It's fast and will catch most differences.

> 2 - If the file sizes are smaller than certain size (up to you to find the
> optimal file size), just compare contents through, say, file_get_contents.
> Otherwise move to step 3.
> 3 - Grab some random bytes at the beginning, at the middle and at the end of
> both files and compare them. If they are different, the files are different.
> Otherwise move to step 4.

Not sure about this one. Will all the file operations not create to
much overhead if you are dealing with large files?

> 4 - If you reach this point, you are doomed. You have 2 big files
> that you must
> compare and they are apparently equal so far. Comparing contents will be over
> killing if at all possible, so you will want to generate hashes and compare
> them. Run md5_file on both files (it would be great if you have,
> say, file A's
> hash already calculated and stored in a DB or data file) and compare results.
>
> It is always up to what kind of files you are dealing with, if the files are
> often different only at the end of the stream, you may want to skip
> step 2. But
> this is what I would generally do.
>
> By the way, md5 is a great hashing function, but it is not bullet-proof,
> collisions may happen (though it's much better than crc32, for
> example). So, you

MD5 is for sure not bullet-proof. You could always switch to sha1_file for a
bit more security.

> may also think of how critical is to you to have some false positives (some
> files that are considered equal by md5_file and they are not) and
> probably use
> some diff-like solution instead of md5_file. Anyway, having compared
> sizes and
> random bytes (steps 1 through 3), it's very likely that md5_file
> will catch it
> if two files are different in just a few bytes.
>
> Regards,
>
> Rob
>
> Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview
> Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 |
> TEL 954-607-4207 | FAX 954-337-2695 |
> Email: infobestplace.net | MSN Chat: bestbestplace.net | SKYPE:
> bestplace |
> Web: bestplace.biz | Web: seo-diy.com
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Hi,

I am learning PHP, I am trying to set a simple cookie:

<html>
        <head>
                <title>Cookies</title>
        </head>
        <body>
                
                <?php setcookie('test', 45, time()+(60*60*24*7)); ?>
                
        </body>
</html>

Firefox is returning this error:

Warning: Cannot modify header information - headers already sent by
(output started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in /
Users/Daff/Sites/php_sandbox/cookies.php on line 7

I have googled this and can't find out what I am doing wrong. Any
help you could give me would be much appreciated.

Tim

attached mail follows:


> <body>
>
> <?php setcookie('test', 45, time()+(60*60*24*7)); ?>

from the doc:
"Cookies are part of the HTTP header, so setcookie() must be called before any output is sent to the browser. This is the same limitation that header() has."
http://ca.php.net/cookies

----- Original Message ----
From: Tim Daff <timdaffgmail.com>
To: php-generallists.php.net
Sent: Wednesday, March 12, 2008 8:48:59 AM
Subject: [PHP] setcookie

Hi,

I am learning PHP, I am trying to set a simple cookie:

<html>
    <head>
        <title>Cookies</title>
    </head>
    <body>
        
        <?php setcookie('test', 45, time()+(60*60*24*7)); ?>
        
    </body>
</html>

Firefox is returning this error:

Warning: Cannot modify header information - headers already sent by
(output started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in /
Users/Daff/Sites/php_sandbox/cookies.php on line 7

I have googled this and can't find out what I am doing wrong. Any
help you could give me would be much appreciated.

Tim

      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

attached mail follows:


On Wed, 12 Mar 2008, Tim Daff wrote:

> Hi,
>
> I am learning PHP, I am trying to set a simple cookie:
>
> <html>
> <head>
> <title>Cookies</title>
> </head>
> <body>
> <?php setcookie('test', 45,
> time()+(60*60*24*7)); ?>
> </body>
> </html>
>
> Firefox is returning this error:
>
> Warning: Cannot modify header information - headers already sent by (output
> started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in
> /Users/Daff/Sites/php_sandbox/cookies.php on line 7
>
> I have googled this and can't find out what I am doing wrong. Any help you
> could give me would be much appreciated.
>
> Tim

setcookie from php.net states the following:

setcookie() defines a cookie to be sent along with the rest of the HTTP
headers. Like other headers, cookies must be sent before any output from
your script (this is a protocol restriction). This requires that you place
calls to this function prior to any output, including <html> and <head>
tags as well as any whitespace

call setcookie before you output ANY THING, even error

hope that helps.
t. hiep

attached mail follows:


Even you cant put a space before <?php tag.

the following code will throw the same error.
| <?php
| setcookie();
| ?>
Because I prepend a space for each line

But this will be okay
|<?php
| setcookie();
| ?>

This is a very common mistake and very very hard to find.

On Wed, Mar 12, 2008 at 7:53 AM, Jean-Christophe Roux <jcxxryahoo.com>
wrote:

> > <body>
> >
> > <?php setcookie('test', 45, time()+(60*60*24*7)); ?>
>
> from the doc:
> "Cookies are part of the HTTP header, so setcookie() must be called
> before any output is sent to the browser. This is the same limitation
> that header() has."
> http://ca.php.net/cookies
>
>
> ----- Original Message ----
> From: Tim Daff <timdaffgmail.com>
> To: php-generallists.php.net
> Sent: Wednesday, March 12, 2008 8:48:59 AM
> Subject: [PHP] setcookie
>
> Hi,
>
> I am learning PHP, I am trying to set a simple cookie:
>
> <html>
> <head>
> <title>Cookies</title>
> </head>
> <body>
>
> <?php setcookie('test', 45, time()+(60*60*24*7)); ?>
>
> </body>
> </html>
>
> Firefox is returning this error:
>
> Warning: Cannot modify header information - headers already sent by
> (output started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in /
> Users/Daff/Sites/php_sandbox/cookies.php on line 7
>
> I have googled this and can't find out what I am doing wrong. Any
> help you could give me would be much appreciated.
>
> Tim
>
>
>
>
>
>
> ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile. Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>

attached mail follows:


As a dirty trick you can put following line on the top of your script,
it will work
ob_start();

But you should try to know why it is not working, and what exactly
ob_start will impact your application and What is the thing called
"Output Buffering".

Zareef Ahmed

On 3/12/08, Hiep Nguyen <hiepee.ucr.edu> wrote:
>
> On Wed, 12 Mar 2008, Tim Daff wrote:
>
> > Hi,
> >
> > I am learning PHP, I am trying to set a simple cookie:
> >
> > <html>
> > <head>
> > <title>Cookies</title>
> > </head>
> > <body>
> > <?php setcookie('test', 45,
> > time()+(60*60*24*7)); ?>
> > </body>
> > </html>
> >
> > Firefox is returning this error:
> >
> > Warning: Cannot modify header information - headers already sent by
> (output
> > started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in
> > /Users/Daff/Sites/php_sandbox/cookies.php on line 7
> >
> > I have googled this and can't find out what I am doing wrong. Any help
> you
> > could give me would be much appreciated.
> >
> > Tim
>
>
> setcookie from php.net states the following:
>
> setcookie() defines a cookie to be sent along with the rest of the HTTP
> headers. Like other headers, cookies must be sent before any output from
> your script (this is a protocol restriction). This requires that you place
> calls to this function prior to any output, including <html> and <head>
> tags as well as any whitespace
>
> call setcookie before you output ANY THING, even error
>
> hope that helps.
> t. hiep
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Zareef Ahmed
http://www.zareef.net
A PHP Developer in India

attached mail follows:


Thank's for your help Zareef, Hiep, Shiplu and Jean-Christophe

attached mail follows:


> Firefox is returning this error:
>
> Warning: Cannot modify header information - headers already sent by
> (output started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in
> /Users/Daff/Sites/php_sandbox/cookies.php on line 7

You must use set cookie() before you send any output to the browser,
including whitespace.

--
Richard Heyes
Employ me:
http://www.phpguru.org/cv

attached mail follows:


Tim Daff wrote:
> Hi,
>
> I am learning PHP, I am trying to set a simple cookie:
>
> <html>
> <head>
> <title>Cookies</title>
> </head>
> <body>
>
> <?php setcookie('test', 45, time()+(60*60*24*7)); ?>
>
> </body>
> </html>
>
> Firefox is returning this error:
>
> Warning: Cannot modify header information - headers already sent by
> (output started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in
> /Users/Daff/Sites/php_sandbox/cookies.php on line 7
>
> I have googled this and can't find out what I am doing wrong. Any help
> you could give me would be much appreciated.
>
> Tim

  <?php setcookie('test', 45, time()+(60*60*24*7)); ?>
  <html>
      <head>
          <title>Cookies</title>
      </head>
      <body>

      </body>
  </html>

Cookies HAVE to be at the top of the page... You output ANYTHING else
and you get the error you wound up getting.

Wolf

attached mail follows:


Wolf wrote:
>
>
> Tim Daff wrote:
>> Hi,
>>
>> I am learning PHP, I am trying to set a simple cookie:
>>
>> <html>
>> <head>
>> <title>Cookies</title>
>> </head>
>> <body>
>> <?php setcookie('test', 45, time()+(60*60*24*7)); ?>
>> </body>
>> </html>
>>
>> Firefox is returning this error:
>>
>> Warning: Cannot modify header information - headers already sent by
>> (output started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in
>> /Users/Daff/Sites/php_sandbox/cookies.php on line 7
>>
>> I have googled this and can't find out what I am doing wrong. Any
>> help you could give me would be much appreciated.
>>
>> Tim
>
> <?php setcookie('test', 45, time()+(60*60*24*7)); ?>
> <html>
> <head>
> <title>Cookies</title>
> </head>
> <body>
>
>
>
> </body>
> </html>
>
> Cookies HAVE to be at the top of the page... You output ANYTHING else
> and you get the error you wound up getting.
>
> Wolf
>
>

If you're not sure if data has already been sent to the client (I ran
into an included file having a space after >?) you can use
http://us3.php.net/manual/en/function.headers-sent.php before you call
setcookie();

If nothing else it'll help with diagnosing this error when you run into
it again.

--
Ray Hauge
www.primateapplications.com

attached mail follows:


Hello all,

I'm wondering what's wrong with the use of __autoload(), since I see that
projects like the Zend Framework don't use it and prefer to require_once
each required file.

Thanks in advance.
--
Gustavo Narea.
http://gustavonarea.net/

Get GNU/Linux! http://www.getgnulinux.org/

attached mail follows:


> I'm wondering what's wrong with the use of __autoload(), since I see that
> projects like the Zend Framework don't use it and prefer to require_once
> each required file.

Things that happen without you explicitly causing them (ie require() et
al) can lead to confusion.

For example a junior developer who doesn't know of its existence and is
new to a job is less likely to admit ignorance and ask how a class is
being defined when __autoload() is being used.

--
Richard Heyes
Employ me:
http://www.phpguru.org/cv

attached mail follows:


On 3/12/08, Richard Heyes <richardhphpguru.org> wrote:
> > I'm wondering what's wrong with the use of __autoload(), since I see that
> > projects like the Zend Framework don't use it and prefer to require_once
> > each required file.
>
> Things that happen without you explicitly causing them (ie require() et
> al) can lead to confusion.

It's called "convention over configuration" and that's exactly where
good frameworks should be headed.

http://en.wikipedia.org/wiki/Convention_over_Configuration

> For example a junior developer who doesn't know of its existence and is
> new to a job is less likely to admit ignorance and ask how a class is
> being defined when __autoload() is being used.

That's a the dumbest reason I've ever heard to not use a given language feature.

--
Greg Donald
http://destiney.com/

attached mail follows:


On Wed, 2008-03-12 at 10:33 -0500, Greg Donald wrote:
> On 3/12/08, Richard Heyes <richardhphpguru.org> wrote:
> > > I'm wondering what's wrong with the use of __autoload(), since I see that
> > > projects like the Zend Framework don't use it and prefer to require_once
> > > each required file.
> >
> > Things that happen without you explicitly causing them (ie require() et
> > al) can lead to confusion.
>
> It's called "convention over configuration" and that's exactly where
> good frameworks should be headed.

But then you'd end up with something like Ruby on Rails... and we all
know about Ruby on Rails *VOMIT*.

Who wants to be stuck on a track when they can soar with the eagles.

> http://en.wikipedia.org/wiki/Convention_over_Configuration

Interesting how the article promotes the ideas of both convention and
configuration co-existing so that one doesn't lose versatility. Thus,
one could infer that any good framework would allow both paradigms.

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

attached mail follows:


On 3/12/08, Robert Cummings <robertinterjinn.com> wrote:
> But then you'd end up with something like Ruby on Rails... and we all
> know about Ruby on Rails *VOMIT*.

You clearly don't know much about it or else you wouldn't be bashing
it. Period. Just admit the fact that you're resistant to learn new,
better ways of doing things and move on.

On the other hand, if there's something in Rails you genuinely don't
understand, I'll be happy to assist you with that particular
understanding, off-list or wherever, free of charge.

> Who wants to be stuck on a track when they can soar with the eagles.

I dunno, why not ask the many Rails clone authors? I certainly don't
see any Ruby programmers trying to copy ZF or Symphony.

> > http://en.wikipedia.org/wiki/Convention_over_Configuration
>
> Interesting how the article promotes the ideas of both convention and
> configuration co-existing so that one doesn't lose versatility. Thus,
> one could infer that any good framework would allow both paradigms.

Rails supports both naturally. It has configurable environments for
development, testing, and production, all pre-configured for the most
common cases. You can even create your own new environments if you
have something that doesn't fit into dev/test/prod very easily.
Complete versatility in every regard thanks to Ruby's meta-ness.

--
Greg Donald
http://destiney.com/

attached mail follows:


>> For example a junior developer who doesn't know of its existence and is
>> new to a job is less likely to admit ignorance and ask how a class is
>> being defined when __autoload() is being used.
>
> That's a the dumbest reason I've ever heard to not use a given language feature.

It's a perfectly viable business reason.

--
Richard Heyes
Employ me:
http://www.phpguru.org/cv

attached mail follows:


On 3/12/08, Richard Heyes <richardhphpguru.org> wrote:
> It's a perfectly viable business reason.

No it's not. I guess you need a "business" scenario to wrap your head
around the idiocy.

Here you go:

Imagine at Blizzard one morning, "Hey guys, we're not going to be able
to use function pointers on the new Diablo III like we had planned to
do, the new hires down the hall don't understand them very well so
just don't use them, OK?"

--
Greg Donald
http://destiney.com/

attached mail follows:


On Wed, Mar 12, 2008 at 10:05 AM, Gustavo Narea <megustavonarea.net> wrote:
> Hello all,
>
> I'm wondering what's wrong with the use of __autoload(), since I see that
> projects like the Zend Framework don't use it and prefer to require_once
> each required file.
>
> Thanks in advance.
> --
> Gustavo Narea.
> http://gustavonarea.net/
>
> Get GNU/Linux! http://www.getgnulinux.org/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Use spl autoload register instead. This way your app and dependent
libraries can have their own autoloaders.

http://us2.php.net/manual/en/function.spl-autoload-register.php

attached mail follows:


>> It's a perfectly viable business reason.
>
> No it's not. I guess you need a "business" scenario to wrap your head
> around the idiocy.
>
> Here you go:
>
> Imagine at Blizzard one morning, "Hey guys, we're not going to be able
> to use function pointers on the new Diablo III like we had planned to
> do, the new hires down the hall don't understand them very well so
> just don't use them, OK?"

That's not quite the situation. Finding good developers isn't easy, so
lots of companies will go for "acceptable" ones, who are less likely to
know of __autoloads existence. Hence, using __autoload is unwise.

--
Richard Heyes
Employ me:
http://www.phpguru.org/cv

attached mail follows:


On 3/12/08, Richard Heyes <richardhphpguru.org> wrote:
> That's not quite the situation. Finding good developers isn't easy, so
> lots of companies will go for "acceptable" ones, who are less likely to
> know of __autoloads existence. Hence, using __autoload is unwise.

A lesser developer should be paid less and should be expected to
produce less but he should not in any way be allowed to refrain from
learning.

How long does it take to understand __autoload() anyway? 5-10
minutes? 15 or 20 if you play with an example for a bit? You're
gonna restrict the entire development team from using a given feature
just because you don't want to invest 20 minutes in getting your
newbie developer up to spead? That's pure idiocy.

--
Greg Donald
http://destiney.com/

attached mail follows:


2008. 03. 12, szerda keltezéssel 11.12-kor Greg Donald ezt írta:
> On 3/12/08, Robert Cummings <robertinterjinn.com> wrote:
> > But then you'd end up with something like Ruby on Rails... and we all
> > know about Ruby on Rails *VOMIT*.
>
> You clearly don't know much about it or else you wouldn't be bashing
> it. Period. Just admit the fact that you're resistant to learn new,
> better ways of doing things and move on.

hey, we had a conversation about this a while back, and I'm still not
convinced about RoR being 'better'. it has several cool ideas, which
some php frameworks also follow now (and a few that would be cool in php
frameworks but not yet implemented), but I strongly think that Ruby as a
language just plain sucks ;)

greets,
Zoltán Németh

>
> On the other hand, if there's something in Rails you genuinely don't
> understand, I'll be happy to assist you with that particular
> understanding, off-list or wherever, free of charge.
>
> > Who wants to be stuck on a track when they can soar with the eagles.
>
> I dunno, why not ask the many Rails clone authors? I certainly don't
> see any Ruby programmers trying to copy ZF or Symphony.
>
> > > http://en.wikipedia.org/wiki/Convention_over_Configuration
> >
> > Interesting how the article promotes the ideas of both convention and
> > configuration co-existing so that one doesn't lose versatility. Thus,
> > one could infer that any good framework would allow both paradigms.
>
> Rails supports both naturally. It has configurable environments for
> development, testing, and production, all pre-configured for the most
> common cases. You can even create your own new environments if you
> have something that doesn't fit into dev/test/prod very easily.
> Complete versatility in every regard thanks to Ruby's meta-ness.
>
>
> --
> Greg Donald
> http://destiney.com/
>

attached mail follows:


Greg Donald wrote:
> On 3/12/08, Richard Heyes <richardhphpguru.org> wrote:
>> That's not quite the situation. Finding good developers isn't easy, so
>> lots of companies will go for "acceptable" ones, who are less likely to
>> know of __autoloads existence. Hence, using __autoload is unwise.
>
> A lesser developer should be paid less and should be expected to
> produce less but he should not in any way be allowed to refrain from
> learning.

I agree. But having worked in the (then) fast paced environment of
online DVD rental, time was not available.

> How long does it take to understand __autoload() anyway? 5-10
> minutes?

I would say as long as it takes to read the manual page, which isn't
that long at all.

> You're
> gonna restrict the entire development team from using a given feature
> just because you don't want to invest 20 minutes in getting your
> newbie developer up to spead? That's pure idiocy.

No it's not. It's not like require_once() is a hassle to type/use
anyhow. Things like editor macros and templates help out enormously and
by using them over __auto load you (a business) could save yourself a
lot of time and hence money.

--
Richard Heyes
Employ me:
http://www.phpguru.org/cv

attached mail follows:


On 3/12/08, Zoltán Németh <znemethalterationx.hu> wrote:
> but I strongly think that Ruby as a
> language just plain sucks ;)

And exactly how many projects do you have under your belt to allow you
to develop this opinion? What's the url to any one of them?

Unlike you I actually have thousands of lines of Ruby code under my
belt that allows me to properly develop an opinion of Ruby and Rails
and how they both compare to every other programming language and
framework I know and have developed in. Need a URL?

--
Greg Donald
http://destiney.com/

attached mail follows:


On Wed, 2008-03-12 at 11:12 -0500, Greg Donald wrote:
> On 3/12/08, Robert Cummings <robertinterjinn.com> wrote:
> > But then you'd end up with something like Ruby on Rails... and we all
> > know about Ruby on Rails *VOMIT*.
>
> You clearly don't know much about it or else you wouldn't be bashing
> it. Period.

Ummm, I've looked into Ruby and RoR. I've tried it out. I've read many
many many articles on it. I JUST DON'T LIKE IT.

> Just admit the fact that you're resistant to learn new,
> better ways of doing things and move on.

Ooooh... a personal attack... what a great way to make me reflect upon
my dislike of RoR. I think the only person around here qualified to
throw around "facts" about me is... you know... ME!

> On the other hand, if there's something in Rails you genuinely don't
> understand, I'll be happy to assist you with that particular
> understanding, off-list or wherever, free of charge.

Oh, there's nothing I don't understand about it. I just don't like it.
Can't a person just not like something anymore? Can't I have my own
opinion anymore? What year is this? 1984?? ... In an alternate universe
that was supposed to be averted?

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

attached mail follows:


On Wed, 2008-03-12 at 11:26 -0500, Greg Donald wrote:
> On 3/12/08, Richard Heyes <richardhphpguru.org> wrote:
> > It's a perfectly viable business reason.
>
> No it's not. I guess you need a "business" scenario to wrap your head
> around the idiocy.
>
> Here you go:
>
> Imagine at Blizzard one morning, "Hey guys, we're not going to be able
> to use function pointers on the new Diablo III like we had planned to
> do, the new hires down the hall don't understand them very well so
> just don't use them, OK?"

This is not a valid comparison. The above is the replacement of one
convention with another convention. It is not a case of circumventing a
convention to achieve a specific, and probably desired outcome.

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

attached mail follows:


On 3/12/08, Richard Heyes <richardhphpguru.org> wrote:
> No it's not. It's not like require_once() is a hassle to type/use
> anyhow. Things like editor macros and templates help out enormously and
> by using them over __auto load you (a business) could save yourself a
> lot of time and hence money.

I'm not defending __autoload() specifically, I don't do much OO PHP
anyway so I couldn't possibly care less about it. My argument is that
asking other developers to not use specific language features simply
because lesser developers may not know them very well is just plain
dumb. I'm sorry you don't get it and I'm done trying to help you get
it. Good luck codling your lesser developers. May they never learn
jack on their own.

*sigh*

--
Greg Donald
http://destiney.com/

attached mail follows:


On 3/12/08, Robert Cummings <robertinterjinn.com> wrote:
> > Imagine at Blizzard one morning, "Hey guys, we're not going to be able
> > to use function pointers on the new Diablo III like we had planned to
> > do, the new hires down the hall don't understand them very well so
> > just don't use them, OK?"
>
> This is not a valid comparison. The above is the replacement of one
> convention with another convention. It is not a case of circumventing a
> convention to achieve a specific, and probably desired outcome.

It's a dead-on, same example, just with a different programming
language and a different language feature.

--
Greg Donald
http://destiney.com/

attached mail follows:


2008. 03. 12, szerda keltezéssel 12.12-kor Greg Donald ezt írta:
> On 3/12/08, Zoltán Németh <znemethalterationx.hu> wrote:
> > but I strongly think that Ruby as a
> > language just plain sucks ;)
>
> And exactly how many projects do you have under your belt to allow you
> to develop this opinion? What's the url to any one of them?
>
> Unlike you I actually have thousands of lines of Ruby code under my
> belt that allows me to properly develop an opinion of Ruby and Rails
> and how they both compare to every other programming language and
> framework I know and have developed in. Need a URL?

ok, I admit I don't have experience with Ruby but I have experience with
php. and I don't have experience with Ruby because I read some manuals
and example codes and whatnot and I just could not get to like it at
all. it's just so strange and different from anything I know (php, c,
java) - and I could not find out any good reasons for most of the
differences... e.g. how come function definitions are between 'def' and
'end'? I just don't like it and it's a matter of taste, so there is no
need to argue about it more... :)

however that's not about the framework, I admit that Rails had several
new and useful concepts, and I know that the framework I currently use
took a lot of ideas from there.

greets,
Zoltán Németh

>
>
> --
> Greg Donald
> http://destiney.com/
>

attached mail follows:


---- Richard Heyes <richardhphpguru.org> wrote:
> Greg Donald wrote:
> > On 3/12/08, Richard Heyes <richardhphpguru.org> wrote:
> >> That's not quite the situation. Finding good developers isn't easy, so
> >> lots of companies will go for "acceptable" ones, who are less likely to
> >> know of __autoloads existence. Hence, using __autoload is unwise.
> >
> > A lesser developer should be paid less and should be expected to
> > produce less but he should not in any way be allowed to refrain from
> > learning.
>
> I agree. But having worked in the (then) fast paced environment of
> online DVD rental, time was not available.

Learning always has to happen, even if you don't think it is... Some are just slower then others.

> > How long does it take to understand __autoload() anyway? 5-10
> > minutes?
>
> I would say as long as it takes to read the manual page, which isn't
> that long at all.

And you have to couple in with that the person's mental capacity for what they are trying to learn, their background, and if they have any other knowledge of the subject.

> > You're
> > gonna restrict the entire development team from using a given feature
> > just because you don't want to invest 20 minutes in getting your
> > newbie developer up to spead? That's pure idiocy.
>
> No it's not. It's not like require_once() is a hassle to type/use
> anyhow. Things like editor macros and templates help out enormously and
> by using them over __auto load you (a business) could save yourself a
> lot of time and hence money.

I actually prefer to use a site prepend and append, then in the prepend file is where I throw all my requires and such. pretty much takes care of any learning curve since with the prepended file doing the heavy lifting.

Wolf

attached mail follows:


On Wed, 2008-03-12 at 18:21 +0100, Zoltán Németh wrote:
> 2008. 03. 12, szerda keltezéssel 12.12-kor Greg Donald ezt írta:
> > On 3/12/08, Zoltán Németh <znemethalterationx.hu> wrote:
> > > but I strongly think that Ruby as a
> > > language just plain sucks ;)
> >
> > And exactly how many projects do you have under your belt to allow you
> > to develop this opinion? What's the url to any one of them?
> >
> > Unlike you I actually have thousands of lines of Ruby code under my
> > belt that allows me to properly develop an opinion of Ruby and Rails
> > and how they both compare to every other programming language and
> > framework I know and have developed in. Need a URL?
>
> ok, I admit I don't have experience with Ruby but I have experience with
> php. and I don't have experience with Ruby because I read some manuals
> and example codes and whatnot and I just could not get to like it at
> all. it's just so strange and different from anything I know (php, c,
> java) - and I could not find out any good reasons for most of the
> differences... e.g. how come function definitions are between 'def' and
> 'end'?

Because they didn't follow convention... *HAHAHA* oh my, I think I just
pee'd myself.

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

attached mail follows:


On 12 Mar 2008, at 17:31, Wolf wrote:
> ---- Richard Heyes <richardhphpguru.org> wrote:
>> Greg Donald wrote:
>>> You're
>>> gonna restrict the entire development team from using a given
>>> feature
>>> just because you don't want to invest 20 minutes in getting your
>>> newbie developer up to spead? That's pure idiocy.
>>
>> No it's not. It's not like require_once() is a hassle to type/use
>> anyhow. Things like editor macros and templates help out enormously
>> and
>> by using them over __auto load you (a business) could save yourself a
>> lot of time and hence money.
>
> I actually prefer to use a site prepend and append, then in the
> prepend file is where I throw all my requires and such. pretty much
> takes care of any learning curve since with the prepended file doing
> the heavy lifting.

But by doing so you're including a lot of code you almost certainly
don't use on every page. That can pointlessly consume resources on a
busy server.

I use __autoload (and for new projects the SPL version) because I know
that anyone who can't "get it" within 5 minutes is not someone I want
to work with.

Not using language features because some developers might not know
about it is going to restrict you to the sort of instruction set you
get in Assembler. I've been working with PHP for a very long time and
I certainly don't claim to know everything about it or about every
feature it has. Restrict your code in that way and you'll create a
slow unmaintainable mess.

IMHO.

-Stut

--
http://stut.net/

attached mail follows:


On 3/12/08, Zoltán Németh <znemethalterationx.hu> wrote:
> ok, I admit I don't have experience with Ruby but I have experience with
> php. and I don't have experience with Ruby because I read some manuals
> and example codes and whatnot and I just could not get to like it at
> all.

That's a lot different from your previous blanket statement of "Ruby
as a language just plain sucks". I hate you less now that I know a
bit more about you, see how that works?

> it's just so strange and different from anything I know (php, c,
> java) -

Ruby has a lot of functional language influence. Once you use it you
really start to like how much shorter your iterative loops are for
example. The first two developers I worked with using Ruby also knew
ML and Scheme. One of them suggested I go study Scheme so I would
appreciate Ruby more. I did so for several weeks and now I do. Ruby
provides everything from the procedural world we're currently used to
seeing in PHP, C, and Java, but it also adds functional style that
makes for some utterly beautiful, compact code.

> and I could not find out any good reasons for most of the
> differences...

And you won't until you use it in practice more than once. But that's
true of most any language. I worked in Python by day for the better
part of last year and man was it fun seeing other ideas for how to do
things.

> e.g. how come function definitions are between 'def' and
> 'end'?

def is shorter than PHP's "function" qualifier? I give up. 'end' is
optionally replacable with '}', as is 'do' and '{' but you probably
didn't ever get to that page in the Ruby book you read.

> I just don't like it and it's a matter of taste,

In my experience "matter of taste" usually equates to "resistance to
learning", but call it what you will.

> so there is no
> need to argue about it more... :)

There's always reason to argue the features of a given language. For
example you may need to try and convince me at some point that Zombie
is a great language:

http://www.dangermouse.net/esoteric/zombie.html

Or not.

> however that's not about the framework, I admit that Rails had several
> new and useful concepts, and I know that the framework I currently use
> took a lot of ideas from there.

Those other frameworks can never be as powerful as Rails because they
aren't written in something as meta-capable as Ruby. Can you do this
in PHP?

class Foo
end

f = Foo.new

class Foo
  Resource.find( :all ).each do |r|
    res = r.name.downcase
    define_method( "op_cost_#{ res }".to_sym ) do
      self.properties.inject( 0 ){ |c,p| c + p.send( "op_cost_#{ res }" ) }
    end
  end
end

cost = f.op_cost_wheat

No you can't. PHP doesn't support adding methods to classes at
runtime, nor does it support adding methods to instantiated objects of
those classes at runtime. And that's just one example. These sort of
OO advantages exist throughout Ruby.

You don't love these features because you don't know they exist. You
don't know they exist because you haven't given the language more than
a few minutes of your time. Running through some silly little 5
minute Rails scaffolding tutorial will in no way teach you the real
power that exists in Ruby.

--
Greg Donald
http://destiney.com/

attached mail follows:


2008. 03. 12, szerda keltezéssel 13.27-kor Greg Donald ezt írta:
> On 3/12/08, Zoltán Németh <znemethalterationx.hu> wrote:
> > ok, I admit I don't have experience with Ruby but I have experience with
> > php. and I don't have experience with Ruby because I read some manuals
> > and example codes and whatnot and I just could not get to like it at
> > all.
>
> That's a lot different from your previous blanket statement of "Ruby
> as a language just plain sucks". I hate you less now that I know a
> bit more about you, see how that works?

didn't you notice the smiley at the end of that line? that was not a
serious plain statement but some mocking at you because you made a plain
statement about RoR being better.

>
> > it's just so strange and different from anything I know (php, c,
> > java) -
>
> Ruby has a lot of functional language influence. Once you use it you
> really start to like how much shorter your iterative loops are for
> example. The first two developers I worked with using Ruby also knew
> ML and Scheme. One of them suggested I go study Scheme so I would
> appreciate Ruby more. I did so for several weeks and now I do. Ruby
> provides everything from the procedural world we're currently used to
> seeing in PHP, C, and Java, but it also adds functional style that
> makes for some utterly beautiful, compact code.

'utterly beautiful' is again a matter of taste :)
of course, I admit that Ruby would provide me all the features I
currently use, it has to, otherwise noone would start using it instead
of their current language. and yes, I see from the examples that it is
shorter. but is shortness/compactness such a great advantage? I'm not at
all sure about that.

>
> > and I could not find out any good reasons for most of the
> > differences...
>