[Opgelost][PHP] tot de tweede

Gestart doorAlemaalte5 reacties41 weergaven

6 berichten · pagina 1 van 1

Alemaalte

Lid · Topicstarter

Berichten
5.957
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Opgelost
oplossing: Je mag ^ in php niet gebruiken voor macten.

Heej one2xsertjes,

Ik heb een klein probleempje met mijn php script. Dit is het script:

[COLOR= #0000BB]<?php[/COLOR]
                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row1[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]x[/COLOR][COLOR= #007700]] >[/COLOR] [COLOR= #0000BB]$row2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]x[/COLOR][COLOR= #007700]])
                    {[/COLOR]
                    
                        [COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row1[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]x[/COLOR][COLOR= #007700]];[/COLOR]
                        [COLOR= #0000BB]$b[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]x[/COLOR][COLOR= #007700]];
                    
                    }[/COLOR]
                [URL="http://www.php.net/else"]else[/URL]
                    [COLOR= #007700]{[/COLOR]
                    
                        [COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]x[/COLOR][COLOR= #007700]];[/COLOR]
                        [COLOR= #0000BB]$b[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row1[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]x[/COLOR][COLOR= #007700]];
                    
                    }[/COLOR]
                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row1[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]y[/COLOR][COLOR= #007700]] >[/COLOR] [COLOR= #0000BB]$row2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]y[/COLOR][COLOR= #007700]])
                    {[/COLOR]
                    
                        [COLOR= #0000BB]$c[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row1[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]y[/COLOR][COLOR= #007700]];[/COLOR]
                        [COLOR= #0000BB]$d[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]y[/COLOR][COLOR= #007700]];
                    
                    }[/COLOR]
                [URL="http://www.php.net/else"]else[/URL]
                    [COLOR= #007700]{[/COLOR]
                    
                        [COLOR= #0000BB]$c[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]y[/COLOR][COLOR= #007700]];[/COLOR]
                        [COLOR= #0000BB]$d[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row1[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]y[/COLOR][COLOR= #007700]];
                    
                    }[/COLOR]
                
                [COLOR= #0000BB]$stap1[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$b[/COLOR][COLOR= #007700];[/COLOR]
                [COLOR= #0000BB]$stap1b[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$c[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$d[/COLOR][COLOR= #007700];[/COLOR]
                [COLOR= #0000BB]$twee[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]2[/COLOR][COLOR= #007700];[/COLOR]
                [COLOR= #0000BB]$stap2[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$stap1[/COLOR] [COLOR= #007700]^[/COLOR] [COLOR= #0000BB]$twee[/COLOR][COLOR= #007700];[/COLOR]
                [COLOR= #0000BB]$stap2b[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$stap1b[/COLOR] [COLOR= #007700]^[/COLOR] [COLOR= #0000BB]$twee[/COLOR][COLOR= #007700];[/COLOR]
                [COLOR= #0000BB]$stap3[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$stap2[/COLOR] [COLOR= #007700]+[/COLOR] [COLOR= #0000BB]$stap2b[/COLOR][COLOR= #007700];[/COLOR]
                [COLOR= #0000BB]$afstand[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/sqrt"]sqrt[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$stap3[/COLOR][COLOR= #007700]);[/COLOR]
                
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]$Aftsand:[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$afstand[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]$stap3[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$stap3[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]$a[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$a[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]$b[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$b[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]$c[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$c[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]$d[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$d[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]$a - $b[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$stap1[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]$c - $d[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$stap1b[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]$stap1 ^ 2[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$stap2[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]$stap1b ^ 2[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$stap2b[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]$stap2 + $stap2b[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$stap3[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br>[/COLOR][COLOR= #007700];[/COLOR]
?>


En dit geeft hij weer

$Aftsand:
2.64575131106

$stap3
7

$a
10
$b
3
$c
2
$d
2
$a - $b
7
$c - $d
0
$stap1 ^ 2
5
$stap1b ^ 2
2
$stap2 + $stap2b
7


Wie ziet de fout?

Alvast bedankt.
0
Berichten
10.409
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Is de output letterlijk

$Aftsand:
2.64575131106

$stap3
7

$a
10
$b
3
$c
2
$d
2
$a - $b
7
$c - $d
0
$stap1 ^ 2
5
$stap1b ^ 2
2
$stap2 + $stap2b
7
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
En wat gaat er niet zoals je wilt?
0
Alemaalte

Lid · Topicstarter

Berichten
5.957
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
@kingunit
Ja de output is letterlijk.
@sjoerd
7 ^2 != 5
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Je mag ^ wel in PHP gebruiken, maar dat is een bitwise operator:

$a ^ $b    Xor (exclusive or)    Bits that are set in $a or $b but not both are set.
0
Alemaalte

Lid · Topicstarter

Berichten
5.957
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Er staat dan ook voor machten achter.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren