Re: EMPTY??
| From: | Chen Lei | Date: | Wed, 24 Oct 2007 15:48:54 +0000 |
| Subject: | Re: EMPTY?? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263596@lists.php.net to get a copy of this message | ||
Can you show us the form tag of your php file(html code)?
Dan Shirah 写道:
doing a var_dump($_POST['comments']; returns string(0) "" So the value of $comments in $comments = $_POST['comments']; SHOULD be equal to 0 or "", right? In which case when I do my original: if (!empty($comments)) { echo "Do Something"; } It SHOULD just bypass that and continue with my code, but instead it gives me the error, "Changed database context to Database." On 10/23/07, Nathan Nobbe <quickshiftin@gmail.com> wrote:try using var_dump(); you will see that it is a string that has no contents, or perhaps some whitespace characters. -nathanOn 10/23/07, Dan Shirah <mrsquash2@gmail.com> wrote:no; strtoupper modifies its argument, that is all. empty evaluates the argument it is given that is all. therefore, if empty is passed an string with no contents that has been passed through strtoupper, it will still be regarded as empty. <?phpdoes not work with strtoupper in front of the value. It only works with a standalone variable, correct?I made two variables for the same posted value because I believe empty()$var = strtoupper(''); if(empty($var)) { echo 'var is empty'; }?>it returns nothing at all which is why I think empty() or "" should work, but they don't.When comments is left blank and I echo out the value for $check_comments