1. #1
    -Vipr-'s Avatar
    Registered
    28/04/04
    Location
    Reet
    Posts
    466
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    0/0

    PHP Vergelijkings operatoren

    ik krijg voor x1 en x2 nooit waarden :/ zou iemand kunnen zeggen waaraan dit ligt?
    misschien een grote fout in mijn verg. operatoren ?

    PHP Code:
    case 2:
            
    while (
    $x1 != $x2 and $x1 == 0)
            
    {
        
    $x1 rand(-10,10);
        
    $x2 rand(-10,10);
                
    }
            
    while (
    $a == 0)
    {
        
    $a rand(-2,2);
    }
            
    $b = -$a $x3;
    $c $a * ($x1 $x1);
            
    echo 
    "$rgetal<br>";
    echo 
    $a x² + $b x + $c <br>";
    echo 
    "$x1 && $x2";
            
    break; 
    no votes  

  2. #2
    den Acid Burn's Avatar
    Registered
    27/05/03
    Location
    Aarschot
    Posts
    2,403
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    0/0
    while ($x1 != $x2 and $x1 == 0)

    ik heb nog nie echt ervaring me php, maar in java zou zo iets zijn:

    while (($x1 != $x2) && ($x1 == 0))

    volges mij zal dit wel werken
    no votes  

  3. #3

    Registered
    18/11/02
    Location
    Eke, België
    Posts
    2,448
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    0/0
    @Acid Burn, beide zijn correct

    @Vipr
    Wat zijn de beginwaarden van uw x1 en x2 en $a als ik vragen mag, want als ik het volgende doe dan krijg ik wel resultaten:

    PHP Code:
    $x1 0;
    $x2 = -1;
    $a 0;

    while (
    $x1 != $x2 and $x1 == 0
             

        
    $x1 rand(-10,10); 
        
    $x2 rand(-10,10); 
                 

             
    while (
    $a == 0

        
    $a rand(-2,2); 

             
    $b = -$a $x3
    $c $a * ($x1 $x1); 
             
    echo 
    "$rgetal<br>"
    echo 
    $a x² + $b x + $c <br>"
    echo 
    "$x1 && $x2"
    Met andere woorden in uw geval wordt er nooit in die eerte lus gegaan, wat mijdoet vermoeden dat uw $x1 en $x2 beide 0 zijn.

    Of is uw conditie van uw eerste while lus verkeerd?
    no votes  

  4. #4

    Registered
    12/10/02
    Location
    mars
    Posts
    14,319
    iTrader
    2 (100%)
    Mentioned
    0 Post(s)
    Reputation
    0/0
    als x1 en x2 niet geset zijn zal het idd niet deftig werken en ik snap tbh jouw manier van rand-calculation niet goed (omslachtig imho).
    no votes  

  5. #5
    servi's Avatar
    Registered
    01/07/02
    Location
    Zolder
    Posts
    2,487
    iTrader
    6 (100%)
    Mentioned
    0 Post(s)
    killgore :
    ik denk eerder dat het gewoon wat voor te testen is dat hij dit alles schrijft
    no votes  

  6. #6
    icerulez's Avatar
    Registered
    17/07/02
    Location
    Evergem
    Posts
    844
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    0/0
    wa zit er in uwen switch als ik vragen mag ? als $x1 in uw switch zit zal het nooit werken...
    no votes  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Log in

Log in