Home  >  Q&A  >  body text

Is it also true if true here is changed to any character?

<?php

//Define the winning variable. The value of the variable is true, which means you have won the prize.

$zhongjiang = u;

//Because $ zhongjiang The result is true, so it displays: "Buy a House"

//You can change it to false to try the execution result. If it is false, echo 'Buy a House' will not be executed;


if($zhongjiang){

echo 'Buy a house';

}

//Follow-up code

echo 'What should you do?';

?>


phpcn_u1458phpcn_u14581945 days ago1500

reply all(3)I'll reply

  • 小陈

    小陈2019-07-20 22:10:10

    If the judgment condition behind if asks about a variable, and its value is the following situations, it will return false

    1: Boolean value FALSE
    2: Integer value 0 (zero)
    3: Floating point value 0.0 (zero)
    4: Blank string and string "0"
    5: Array without member variables
    6: Object without cells (only for PHP 4)
    7: Special type NULL (including variables that have not been set)

    reply
    0
  • angryTom

    angryTom2019-07-18 08:59:59

    By default, 0 is false and non-0 is true. You can use this idea. If the variable is empty, it will also be judged as false.

    reply
    0
  • phpcn_u1458

    That's it, that is, when the value is 0, it is false, and for characters other than 0, which does not include Chinese, it is true. Thanks for the answer.

    phpcn_u1458 · 2019-07-19 04:32:02
  • Cancelreply