Home  >  Article  >  Backend Development  >  String equality and deletion of variables in php

String equality and deletion of variables in php

WBOY
WBOYOriginal
2016-07-25 09:07:251142browse
  1. $a='11';
  2. $b=11;
  3. if($a===$b)
  4. {
  5. echo 'strict equality';
  6. }
  7. else if($ a==$b)
  8. {
  9. echo 'equal';
  10. }
  11. else
  12. {
  13. echo 'not equal';
  14. }
Copy code

The results are equal.

Here’s how to delete elements in an array:

Examples are as follows:

  1. $_POST=array("firstname"=>'f',"lastname"=>'j',"email"=>"fj@qq.com", "password"=>"123",'rpassword'=>"123");
  2. $user=$_POST;
  3. function deletearray($user)
  4. {
  5. foreach($user as $key => $value )
  6. {
  7. if($key=='firstname')
  8. {
  9. unset($user[$key]);
  10. }
  11. else
  12. {
  13. return true;
  14. }
  15. }
  16. }
  17. deletearray($user);
  18. print_r($user);
Copy code

Remarks: At first I couldn't delete firstname. I always thought it was an error with ==. Later I found out that an error occurred when calling the function. If you want to change the incoming array, you should pass in &$user. That is, pass in Only by inserting a reference can the result of the array be changed.



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn