Dus return $colort; ?
Captcha Class.
Jep, en bij die colorl() ook (maar daar return $colorl; natuurlijk
).
).Oki. En hoe kan ik random kleuren gebruiken?

imagecolorallocate($cap, rand(0, 255), rand(0, 255), rand(0, 255));
Zorg alleen wel dat je leesbare kleuren krijgt, je moet dus wat met die waarden knoeien om de goede over te houden.
Zorg alleen wel dat je leesbare kleuren krijgt, je moet dus wat met die waarden knoeien om de goede over te houden.
Ok. Alleen ik krijg steeds Array erin staan...
Ja, omdat je $this->code() erop weergeeft terwijl dat een array is.
Je moet code() dus aanpassen zodat je een string terugkrijgt (en niet een array met het hele alfabet + alle cijfers).
Je moet code() dus aanpassen zodat je een string terugkrijgt (en niet een array met het hele alfabet + alle cijfers).
En hoe doe je dat? 


Door willekeurige karakters uit $chars te pakken en die achter elkaar te plakken en vervolgens te returnen.
Zoiets dus:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] code[COLOR= #007700]()
{[/COLOR]
[COLOR= #FF8000]// De letters en cijfers in een variabel zetten[/COLOR]
[COLOR= #0000BB]$chars[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array_merge"]array_merge[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/range"]range[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]a[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]z[/COLOR][COLOR= #007700]) &&[/COLOR] [URL="http://www.php.net/range"]range[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]A[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]Z[/COLOR][COLOR= #007700]) &&[/COLOR] [URL="http://www.php.net/range"]range[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]9[/COLOR][COLOR= #007700]));[/COLOR]
[COLOR= #FF8000]// De letters en cijfers weergeven[/COLOR]
[COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]4[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]8[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$ret[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$chars_count[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$chars[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]$count[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++)
{[/COLOR]
[COLOR= #0000BB]$ret[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #0000BB]$chars[/COLOR][COLOR= #007700][[/COLOR][URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$chars_count[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]];
}[/COLOR]
[URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$ret[/COLOR][COLOR= #007700];
}[/COLOR] Als ik dat doe, komt er geen tekst in.
misschien die &&s weer met ,s veranderen.
ohja.
je geeft ze ook lekker dezelfde kleur ?
ohja.
[COLOR= #0000BB]<?[/COLOR]
[COLOR= #FF8000]// De lijn kleur[/COLOR]
[URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] colorl[COLOR= #007700]()
{[/COLOR]
[COLOR= #FF8000]// De lijn een kleur geven[/COLOR]
[COLOR= #0000BB]$colorl[/COLOR] [COLOR= #007700]=[/COLOR] imagecolorallocate[COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]cap[COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]);
}[/COLOR]
[COLOR= #FF8000]// De tekst kleur[/COLOR]
[URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] colort[COLOR= #007700]()
{[/COLOR]
[COLOR= #FF8000]// De tekst een kleur geven[/COLOR]
[COLOR= #0000BB]$colort[/COLOR] [COLOR= #007700]=[/COLOR] imagecolorallocate[COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]cap[COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]);
}[/COLOR]
?> je geeft ze ook lekker dezelfde kleur ?
Nu niet meer, en die &&s heb ik veranderd naar kommas.
Zoek eens uit wat de functie code() teruggeeft.
// De code functie
public function code()
{
// De letters en cijfers in een variabel zetten
$chars = array_merge(range(a, z), range(A, Z), range(0, 9));
// De letters en cijfers weergeven
$count = rand(4, 8);
$ret = ;
$chars_count = count($chars);
for($i = 0; $i<$count; $i++)
{
$ret .= $chars[rand(0, $chars_count - 1)];
}
return $ret;
} Dat is m nu.
Lennard schreef:edit: bij mij doet hij het: http://82.217.238.64/eriktroep/test.phpZoek eens uit wat de functie code() teruggeeft.
als ik public tenminste weghaal omdat hij bij mij niet in een class zit

http://82.217.238.64/eriktroep/test2.php
captcha werkt ook gewoon bij mij??
Hier ook..
