Re: [PHP] $_post and array question
Thanks for help Daniel Clark. I know i must use isset function but that was not the issue. But thanks anyway:) Curt Zirzow thanks for your reply also. But that has nothing to do with reference. If you use reference or not.. it still would not result in an error (hee... I want an error :P) Matt Matijevich thanks for your reply as well :) My function is already declared something like this: function testX($testArr) { $arr_test = $testArr; return $arr_test; } Even if you send a reference parameter ($testArr).. the outcome will not result in an error. I guess somehow PHP does something to the function argument if it does not exist: creating it and give it the NULL value. But this should at least give us a warning because it could result in unwanted code! But i dunno know this for sure. Could anybody help me on this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $_post and array question
Best readers, //PHP version: 4.3.6 I have question concerning the following issue: I have a HTML input element of the type check. input type=checkbox name=test_arr[] let assum this checkbox is unchecked. The checkbox is part of a form. Now we gonna submit this form (post) and gonna catch the POST variable test_arr like this: $arr_test = $_POST[test_arr]; This will result in a novice error Undefined index: Of course because test_arr does not exist. It's unchecked. Now we gonna do the following: We immediately put the $_POST[test_arr] into a function and then we assign $_POST[test_arr] to $arr_test like this: functionX($_POST[test_arr]) $arr_test = $_POST[test_arr]; Knowing that $_POST[test_arr]) does not exist.. this code will not result in a error. Is this a bug,error,etc? Should this not also produce a novice error? Thanks for reading, Amon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $_post and array question
Best readers, //PHP version: 4.3.6 I have question concerning the following issue: I have a HTML input element of the type check. input type=checkbox name=test_arr[] let assum this checkbox is unchecked. The checkbox is part of a form. Now we gonna submit this form (post) and gonna catch the POST variable test_arr like this: $arr_test = $_POST[test_arr]; This will result in a novice error Undefined index: Of course because test_arr does not exist. It's unchecked. Now we gonna do the following: We immediately put the $_POST[test_arr] into a function and then we assign $_POST[test_arr] to $arr_test like this: functionX($_POST[test_arr]) $arr_test = $_POST[test_arr]; Knowing that $_POST[test_arr]) does not exist.. this code will not result in a error. Is this a bug,error,etc? Should this not also produce a novice error? Thanks for reading, Amon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $_post and array question
Best readers, //PHP version: 4.3.6 I have question concerning the following issue: I have a HTML input element of the type check. input type=checkbox name=test_arr[] let assum this checkbox is unchecked. The checkbox is part of a form. Now we gonna submit this form (post) and gonna catch the POST variable test_arr like this: $arr_test = $_POST[test_arr]; This will result in a novice error Undefined index: Of course because test_arr does not exist. It's unchecked. Now we gonna do the following: We immediately put the $_POST[test_arr] into a function and then we assign $_POST[test_arr] to $arr_test like this: functionX($_POST[test_arr]) $arr_test = $_POST[test_arr]; Knowing that $_POST[test_arr]) does not exist.. this code will not result in a error. Is this a bug,error,etc? Should this not also produce a novice error? Thanks for reading, Amon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_post and array question
[snip] functionX($_POST[test_arr]) $arr_test = $_POST[test_arr]; Knowing that $_POST[test_arr]) does not exist.. this code will not result in a error. Is this a bug,error,etc? Should this not also produce a novice error? [snip] I think when you are doing this functionX($_POST[test_arr]) $arr_test = $_POST[test_arr]; $_POST[test_arr] is a local variable to the functionX, not the $_POST superglobal. (I might be wrong) try to define you function like this: functionX($testArr) $arr_test = $testArr; and call it like this: $test = functionX($_POST[test_arr]); //you will probably get your undefined index warning here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_post and array question
I've done a couple things. One is to use isset() and check first. The other is to add a hidden input field, that way something is always sent. input type=hidden name=test_arr[] input type=checkbox name=test_arr[] input type=checkbox name=test_arr[] Best readers, //PHP version: 4.3.6 I have question concerning the following issue: I have a HTML input element of the type check. input type=checkbox name=test_arr[] let assum this checkbox is unchecked. The checkbox is part of a form. Now we gonna submit this form (post) and gonna catch the POST variable test_arr like this: $arr_test = $_POST[test_arr]; This will result in a novice error Undefined index: Of course because test_arr does not exist. It's unchecked. Now we gonna do the following: We immediately put the $_POST[test_arr] into a function and then we assign $_POST[test_arr] to $arr_test like this: functionX($_POST[test_arr]) $arr_test = $_POST[test_arr]; Knowing that $_POST[test_arr]) does not exist.. this code will not result in a error. Is this a bug,error,etc? Should this not also produce a novice error? Thanks for reading, Amon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_post and array question
* Thus wrote Amon ([EMAIL PROTECTED]): functionX($_POST[test_arr]) $arr_test = $_POST[test_arr]; Knowing that $_POST[test_arr]) does not exist.. this code will not result in a error. Is this a bug,error,etc? Should this not also produce a novice error? Taks a look at the definition of functionX I bet it looks something like: function functionX($var) { } The same non-notice effect can be done like: $var = $_POST['test_arr']; This is more of a side effect of assigning by reference. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php