这个参数对if语句有什么作用


What does the parameter do for the if statment?

这个循环做什么?我不知道这意味着什么。我已经试着用互联网来了解这个参数的作用,但我什么都找不到。

if (mysqli_query($conn, $sql)) {
    echo "Table Game Table created successfully";
} else {
    echo "Error creating table: " . mysqli_error($conn);
}

mysqli_query这样的函数返回一个值,在这种情况下,如果它不能正确执行,则返回boolean,即0false (0)(就像你的冰箱也有一个函数一样,你放入牛奶,冷牛奶会被返回,但如果插座没有插上,则无法返回),如果它执行正确,则返回一个object

查询的问题是,我们总是想验证查询是否成功。

if(true){
  # execute this code
} else {
  # otherwise execute this block of code
}
if(($result = mysqli_query($conn, $sql)) != false){ #Translates to: If $result is not equal to false execute the following code.
  # use $result here to print out data.
} else {
  # failed the query cause $result equals to false.
}

它的编程逻辑是1:1,而不是试图弄清楚该函数的作用,而是先尝试在语言中做一些基本的事情。