|
Posted by Rik on 07/14/06 00:04
Chris wrote:
> My goodness Rik, you certainly are sensitive...are you one of the
> writers of the manual? Some of us don't have years of PHP
> programming behind us. I certainly don't, I have only used VB, Perl,
> Javascript, and similar scripting.
Nope, but you've made some odd statements that have to be adressed :-).
>> The manual states very clearly what it does:
>> 1. it _MOVES_ an uploaded file, (it doesn't COPY!!)
>
> actually, in some references I've seen it says it does copy the file
> to the final destination, then deletes the temp file.
Effectively moving it from the coder's perspective.
>> 2. it will return false if filename doesn;t exists or cannot be
>> moved, and true on success
>>
>> Call me simple, but I don't see very much room fort interpretation
>> here.
>>
> interestingly though - using exactly the example from the manual on 2
> different servers - it doesn't work for me. Perhaps it's a server
> issue. File uploads is on in both php.ini files as well as a temp
> directory defined.
Maybe we should adress that issue further instead of this nonsense debate?
Not that I don't enjoy it.
>> Euhm, the same function that does the work is the ideal function to
>> return wether is has succeeded.
>> Also, the function is move_uploaded_file, not moved_uploaded_file.
>
> That was a typo - as everyone makes - including you (see below at
> "mysq_connect" and above at "much room fort" and "wether").
Oh, damn, didn't even realize you made that typo, it was just to illustrate
that it was a function that actually does something, not just returns a
certain state :-). Forgive me for my horrible spelling. I usually know how
things spelled but writing in a foreign language it's more difficult to spot
my mistakes at a glance.
>> I think it's highly logical that a function that has to perform some
>> action
>> will return wether it has succeeded or not. Not only logical, I'd
>> hate to have 2 functions for every action, one to perform it and one
>> te check wether
>> it has succeeded. Seems illogical to me...
>>
>> You'd prefer it if for instance mysq_connect wouldn't return
>> anything, so you'd have to use extra code just to check wether there
>> is a connection to the database?
>>
>
> I simply was stating that it didn't make sense to ask if a function
> worked BEFORE you initiated the function.
That's not what happens. The function is executed on will report on it's
success.
> With mysql_connect you don't encapsulate it within an 'if' statement
> - you simply write the command.
Not?
If seen many, many mysql_connect() or die() statements, next to a lot of
$link = mysql_connect()
if(!$link) {
//die with error
} else {
//continue with code
}
> Imagine encapsulating an echo statement:
>
> <?php if (echo "Hello World"){
> print "congratulations";
> }else{
> print "sorry, dude";
> }?>
1. Echo isn't a function.
2. There are a LOT of functions that will a success-or-failure boolean, that
simply is left unchecked most of the time. Take for instance the simple
sort() function. Very little people actually check wether it returns true or
false, because it usually isn't critical to the script. If it's in the
improper order later, usually the code further on still works. The rare
instances where it does matter, people check. Now there are pieces of code
that are critical to the further script, or to at least inform the user of
it's success or failure. Thats why functions like mysql_select_db(),
move_uploaded_file(), unlink(), mail() are usually checked, while a lot of
others aren't.
But what it boils down to:
You think it's odd that a function that will have to do something
immediately reports back whether it succeeded, I for one am glad a lot of
them do :-).
If we're talking about strange results from functions, I think print() is a
rather peculiar one. (True, like echo, it's not a function either...) It
will return 1. Always. For no reason. Now THAT's something that's odd....
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|