One of the advantages of dynamic languages is that it provides more flexible constructs than static languages.
While it works in two parts, first it is checked fetch_object()
is different from false, if it is (there is a result of the database) comes the second part to which the result is assigned the variable $clientes
, this occurs because of the PHP operator precedence rules .
The assignment operator is one of the least important, so the value of while (true or false) is checked, and if so, the assignment is made.
2- passo 1 - passo
false/ou qualquer coisa
while ($clientes = $resultado->fetch_object()) {
echo $clientes->nome;
echo $clientes->telefone;
}
What can be interpreted as:
while ($clientes = false) //Não entra no while
true
while ($clientes = $resultado->fetch_object())// Faz a atribuição