2
I’m trying to get while to take 2 values to stop but it just doesn’t enter while, I’m starting programming so try to help in a simple way
Objective of the code: To achieve the 0 of a function of 1 degree in a dynamic way...
<?php
print("Qual é o expoente de sua função?\n");
$menu = fgets(STDIN);
if ($menu == 1) {
print("Coloque o valor de A:");
$a = fgets(STDIN);
print("Coloque o valor de B:");
$b = fgets(STDIN);
$xa = 106000;
$xb =-102000;
while($mediaA=0.5 and $mediaB=-0.5){
$resultA = $a*$xa+$b;
$resultB = $a*$xb+$b;
$mediaA = $resultA/2;
$mediaB = $resultB/2;
$resultmedia = $a*$media+$b;
if($mediaA > 0 and $mediaB > 0){
$xb = $resultB;
$xa = $mediaB;
}elseif($resultB<0){
$xa = $mediaA;
$xb = $mediaB;
}elseif($mediaA < 0 and $mediaB < 0) {
$xb = $mediaB;
$xa = $resultA;
}elseif($mediaB>0) {
$xa = $mediaB;
$xb = $mediaA;
}
}
print($mediaA.$mediaB);
}
?>
The
and
in PHP although rare is valid and only differs from&&
in terms of precedence, reference to theand
.– Isac