php - var_dump() returns NULL somehow -
I have created an e-mail address to verify in vaidate and to check whether they match or not.
But this does not work because when I got the var_dump ()
I got the value null
like: NULL String (13) 123@gmail.com
. Can you give me some advice to fix this? I'm completely trapped.
function email_validate_n_match ($ value) {if ($ value == '') returns; If (preg_match ("/ ^ ([a-zA-Z0- 9]) + ([a-zA-Z0-9 \ ._-]) * @ ([a-zA-Z0-9 _-]) + ([A-zA-Z0-9 \ ._-] +) + $ / ", $ value) {static $ count = 0; If ($ count == 0) {$ value1 = $ value; } And if ($ count == 1) {$ value2 = $ value; } Var_dump ($ value2); // if ($ value1 == $ value2) {// return; //} else {// $ this-> Clear = false; // Return $ this- & gt; Tag_st 'does not match'. . $ This- & gt; Tag_ed; //} $ count ++; Return; } And {$ this- & gt; Clear = false; Return $ $-> Tag_st 'Find the correct email address.' . $ This- & gt; Tag_ed; }}
Edit:
Thanks for the reply.
When I put it
Fixed $ calculation = 0; If ($ count == 0) {$ value1 = $ value; Echo '0'; } And if ($ count == 1) {$ value2 = $ value; Echo '1'; }
This outputs 01
. On the other hand,
If I remove the static then I get the code <00> .
So I think this $ count
is working, but I'm still confused why I got the above NULL
result.
You set $ count = 0, then set $ value1 = $ value, but $ value2 Do not set anything as $ $ is not equal to 1, so $ value2 is zero, this is why var_dump gives you zero then you increase the count by using count count + 1, but next time When it moves, the count will be returned to 0.
Comments
Post a Comment