Wat heb jij vandaag geprogrammeerd? 2.0
Een nieuwe zoekmachine op Relisten. Is nog niet live tho.
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] checkform[COLOR= #007700]()
{[/COLOR]
[COLOR= #FF8000]//Maak van de POST vaste waardes[/COLOR]
[COLOR= #0000BB]$getal1[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]getal1[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$getal2[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]getal2[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #FF8000]//Controleer of het wel nummers zijn[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/^[0-9]*$/[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$getal1[/COLOR][COLOR= #007700]) && ![/COLOR][URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/^[0-9]*$/[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$getal2[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Dat zijn geen getallen!"[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$uitkomst[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/sqrt"]sqrt[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$getal1[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]$getal1[/COLOR] [COLOR= #007700]+[/COLOR] [COLOR= #0000BB]$getal2[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]$getal2[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$uitkomst[/COLOR][COLOR= #007700];
}
}[/COLOR]
checkform[COLOR= #007700]();[/COLOR]
?> Robinkoch schreef:Gefeliciteerd, je hebt zojuist het wiel opnieuw uitgevonden[COLOR= #0000BB]<?php[/COLOR] [COLOR= #007700]function[/COLOR] checkform[COLOR= #007700]() {[/COLOR] [COLOR= #FF8000]//Maak van de POST vaste waardes[/COLOR] [COLOR= #0000BB]$getal1[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]getal1[/COLOR][COLOR= #007700]];[/COLOR] [COLOR= #0000BB]$getal2[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]getal2[/COLOR][COLOR= #007700]];[/COLOR] [COLOR= #FF8000]//Controleer of het wel nummers zijn[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/^[0-9]*$/[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$getal1[/COLOR][COLOR= #007700]) && ![/COLOR][URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/^[0-9]*$/[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$getal2[/COLOR][COLOR= #007700])) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Dat zijn geen getallen!"[/COLOR][COLOR= #007700]; }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR] [COLOR= #0000BB]$uitkomst[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/sqrt"]sqrt[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$getal1[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]$getal1[/COLOR] [COLOR= #007700]+[/COLOR] [COLOR= #0000BB]$getal2[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]$getal2[/COLOR][COLOR= #007700]);[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$uitkomst[/COLOR][COLOR= #007700]; } }[/COLOR] checkform[COLOR= #007700]();[/COLOR] ?>
.@Robinkoch waarom die preg match op regel 10? Voldoet [func]is_numeric[/func] of [func]ctype_digit[/func] niet?
Jponsen schreef:Of deze twee wielen. ^@Robinkoch waarom die preg match op regel 10? Voldoet [func]is_numeric[/func] of [func]ctype_digit[/func] niet?
Jessee schreef:Gefeliciteerd, je hebt zojuist het wiel opnieuw uitgevondenEerdere citaten tonen
Robinkoch schreef:[COLOR= #0000BB]<?php[/COLOR] [COLOR= #007700]function[/COLOR] checkform[COLOR= #007700]() {[/COLOR] [COLOR= #FF8000]//Maak van de POST vaste waardes[/COLOR] [COLOR= #0000BB]$getal1[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]getal1[/COLOR][COLOR= #007700]];[/COLOR] [COLOR= #0000BB]$getal2[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]getal2[/COLOR][COLOR= #007700]];[/COLOR] [COLOR= #FF8000]//Controleer of het wel nummers zijn[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/^[0-9]*$/[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$getal1[/COLOR][COLOR= #007700]) && ![/COLOR][URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/^[0-9]*$/[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$getal2[/COLOR][COLOR= #007700])) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Dat zijn geen getallen!"[/COLOR][COLOR= #007700]; }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR] [COLOR= #0000BB]$uitkomst[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/sqrt"]sqrt[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$getal1[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]$getal1[/COLOR] [COLOR= #007700]+[/COLOR] [COLOR= #0000BB]$getal2[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]$getal2[/COLOR][COLOR= #007700]);[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$uitkomst[/COLOR][COLOR= #007700]; } }[/COLOR] checkform[COLOR= #007700]();[/COLOR] ?>
.Dit moest zo voor een school opdracht


Afbeelding niet beschikbaarDe bron kon niet worden geladen (i.imgur.com).Bron openen ↗
Afbeelding niet beschikbaarDe bron kon niet worden geladen (i.imgur.com).Bron openen ↗
Afbeelding niet beschikbaarDe bron kon niet worden geladen (i.imgur.com).Bron openen ↗
Afbeelding niet beschikbaarDe bron kon niet worden geladen (i.imgur.com).Bron openen ↗

toevoeging op 10 juni 2015, 17:54:59:
Afbeelding niet beschikbaarDe bron kon niet worden geladen (i.imgur.com).Bron openen ↗De school rooster app maar geen gebruik van JSON en ik heb geen idee hoe die de data krijgt (ik krijg allemal 302 document removed errors in WireShark). Dus heb ik me eigen "API" gemaakt.
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$cacheFile = "./cache/data.json";
header(Cache-Control: no-cache, must-revalidate);
header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
header(Content-type: application/json);
clearstatcache();
require_once("./json.php");
$rooster = new rocRooster("x", "x", "x");
if(time() - filemtime($cacheFile) >= 7200) {
file_put_contents($cacheFile, $rooster->getCurrentLes());
}
$data = json_decode(file_get_contents($cacheFile));
$data["currentHour"] = $rooster->getLesuur();
echo json_encode($data);
toevoeging op 11 juni 2015, 20:09:19:
niet echt iets productief:
Afbeelding niet beschikbaarDe bron kon niet worden geladen (i.imgur.com).Bron openen ↗Character arithmetic werkt. Dat betekent dat je nu shit als dit kan doen:
Dit geeft [c]I[/c].
x = Hoi
writeln(x[0] + 1) Dit geeft [c]I[/c].
Raoul schreef:Character arithmetic werkt. Dat betekent dat je nu shit als dit kan doen:
x = Hoi
writeln(x[0] + 1) Dit geeft [c]I[/c].
Hoe kom je bij i dan?
0 is toch H?
toevoeging op 12 juni 2015, 21:53:31:
Aaah ik weet het al (ACSII)
inderdaad, ascii
Raoul schreef:Alleen wanneer gebruik je dit nou? Net zoals bitwise snap ik niet wanneer je zoiets nou gebruiktinderdaad, ascii
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
abstract class Animal {
public $name, $age;
public static $animals = 0;
public function __construct() {
self::$animals++;
}
}
interface AnimalIF {
public function setName($name);
public function setAge($age);
public function sayName();
public function sayAge();
}
final class Cat extends Animal implements AnimalIF {
public function sayName() {
echo "naam is: {$this->name}
";
}
public function sayAge() {
echo "leeftijd is: {$this->age}
";
}
public function setName($name) {
$this->name = $name;
}
public function setAge($age) {
$this->age = $age;
}
public function __construct($name, $age) {
$this->setName($name);
$this->setAge($age);
}
public function __destruct() {
parent::__construct();
echo "There are " . (string) parent::$animals . " total animals.
";
}
}
$a = [new Cat("Wollie", 19), new Cat("Jesse", 22)];
foreach($a as $b) {
$b->sayName();
$b->sayAge();
}
Codeblok (voorbeeld.php):
1
2
3
4
5
6
naam is: Wollie
leeftijd is: 19
naam is: Jesse
leeftijd is: 22
There are 1 total animals.
There are 2 total animals.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
abstract class Animal {
public $name, $age;
public static $animals = 0;
public function __construct() {
self::$animals++;
}
}
interface AnimalIF {
public function setName($name);
public function setAge($age);
public function sayName();
public function sayAge();
}
final class Cat extends Animal implements AnimalIF {
public function sayName() {
echo "naam is: {$this->name}
";
}
public function sayAge() {
echo "leeftijd is: {$this->age}
";
}
public function setName($name) {
$this->name = $name;
}
public function setAge($age) {
$this->age = $age;
}
public function __construct($name, $age) {
$this->setName($name);
$this->setAge($age);
}
public function __destruct() {
parent::__construct();
echo "There are " . (string) parent::$animals . " total animals.
";
}
}
$a = [new Cat("Wollie", 19), new Cat("Jesse", 22)];
foreach($a as $b) {
$b->sayName();
$b->sayAge();
}
Codeblok (voorbeeld.php):
1
2
3
4
5
6
naam is: Wollie
leeftijd is: 19
naam is: Jesse
leeftijd is: 22
There are 1 total animals.
There are 2 total animals.

Codeblok (voorbeeld.php):
1
2
3
4
5
6
naam is: Wollie
leeftijd is: 19
naam is: Jesse
leeftijd is: 22
There are 1 total animals.
There are 2 total animals.

1
2
3
4
5
6
naam is: Wollie
leeftijd is: 19
naam is: Jesse
leeftijd is: 22
There are 1 total animals.
There are 2 total animals.
