Common operators and operators in php

Source: Internet
Author: User
& Lt ;? Php * operator number (PHP) operator symbol ** is divided: * 1. arithmetic operators +-* % +-* 2. string operators connected to operators * 3. value assignment operators +-* %
  1. /* Operator number (PHP) operator symbol
  2. *
  3. * By operator number:
  4. * 1. arithmetic operators +-*/% + + --
  5. * 2. string operators. Concatenation Operators
  6. * 3. value assignment operator = + =-= * =/= % =. =
  7. * 4. Comparison operators >======! = <>! =
  8. * Comparison operator --- condition operator --- relational operator
  9. * There is only one comparison result: boolean true false
  10. * === The comparison requires the same content and type
  11. *! = When compared, the content is not the same and the type is also required.
  12. * 5. logical operators & and | or! Or not
  13. * Logical operators can only operate bool-type values, and return bool-type values.
  14. * 6. bitwise operators & | ^ ~ <>>>>
  15. * 7. Other operators? : ''@ =>->::& $
  16. * ''Is used to execute the operating system kernel.
  17. * @ Used to block error messages
  18. * We recommend that you use "()" to change the expression priority.
  19. *
  20. * % Has two purposes: Division operation; control range; do not use decimal places or negative numbers
  21. * % Convert the numbers on both sides of the operator into integers and perform the remainder division.
  22. */
  23. // Use the % symbol to determine the leap year
  24.  
  25. $ Year = 2011;
  26. If ($ year % 4 = 0 & % year % 100! = 0) | $ year % 400 = 0)
  27. {
  28. Echo "run nian ";
  29. }
  30. Else
  31. {
  32. Echo "not run nian ";
  33. }
  34.  
  35.  
  36. // ++ -- Use of symbols
  37. $ A = 10;
  38. $ A ++; // $ a = $ a + 1; first use a variable and then increase by 1
  39. + + $ A; // $ a = $ a + 1; first, auto-Increment 1.
  40. $ A --; // $ a = $ A-1; use variables first, then subtract 1
  41. -- $ A; // $ a = $ A-1; first auto minus 1, then variable
  42. Echo $ a; // The result is 10.
  43.  
  44. // ++ -- Differences in operations
  45. $ A = 10;
  46. $ B = $ a ++; // B = 10, a = 11
  47. $ C = -- $ B; // c = 9, B = 9
  48. $ D = $ c ++ $ c; // d = 20, c = 11
  49. $ E = $ d ----- $ d; // d = 18, e = 2
  50. Echo $ d;
  51.  
  52.  
  53. // Use of the string operator.
  54. $ Name = "tom ";
  55. $ Age = 27;
  56. $ Height = 1.75;
  57. Echo "My name is: {$ name} my age is: {$ age} my height is: {$ height} meters
    ";
  58. Echo 'My name is: '. $ name.' My age is: '. $ age.' My height is: '. $ height. 'MI '.'
    ';
  59. Echo "$ age =". $ age; // $ age = 27
  60.  
  61. Echo "My name is: {$ name} my age is: {$ age} my height is: {$ height} meters
    "; // Use of the value assignment operator
  62.  
  63. $ A = 10;
  64. $ A + = 10; // $ a = $ a + 10;
  65. $ A-= 10; // $ a = $ A-10;
  66. $ A * = 10 ;//...
  67. $ A/= 10 ;//...
  68. $ A % = 10; // $ a = $ a % 10;
  69. $ A. = "abc"; // $ a = $ a. "abc ";
  70. Echo $;
  71. $ Str ='
  72. $ Str. ='
  73. $ Str. ='
  74. $ Str. ='
  75. $ Str. ='
  76. '; '; '; ';
    ';
  77. $ Str. ='
  78. ';
  79. Echo $ str; // output a table
  80. // Comparison operator
  81. Var_dump (15> 6); // return bool (true)
  82. $ A = 15;
  83. If (15 = $)
  84. {
  85. Echo "a = 15 ";
  86. }
  87. Else
  88. {
  89. Echo "! = 15 ";
  90. }
  91.  
  92.  
  93. // Use of logical operators
  94. Var_dump (true & true); // true
  95. Var_dump (true & false); // false
  96. Var_dump (true | false); // true
  97. Var_dump (! True); // false
  98. Var_dump (! False); // true
  99. // Determine the user name and password
  100. $ Username = "admin ";
  101. $ Password = "123456 ";
  102. $ Email = "290080604@qq.com ";
  103. If ($ username = "admin" & $ password = "123456 ")
  104. {
  105. Echo "the user name and password are correct ";
  106. }
  107. If ($ username = "" | $ password = "" | $ email = "")
  108. {
  109. Echo "none of them can be blank ";
  110. }
  111. ?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.