- file_get_contents: documentation ( source)
- stripos: documentation ( source)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Tests linguistiques</title>
</head>
<body>
<br> Testeur de nom <br><br>
<form action="" method="post">
Proposez un nom : <input type="text" name="nom" />
<input type="submit" value="OK">
</form>
<?php
echo file_get_contents("https://www.google.fr");
function requete ($requete) {
$doc = new DOMDocument();
$doc->loadHTMLFile("https://www.google.fr/search?q=%22" . $requete . "%22");
$nombreResultats = $doc->getElementById('resultStats')->nodeValue;
$page = file_get_contents("https://www.google.fr/search?q=%22" . $requete . "%22");
if (stripos($page, "Aucun") == false) {
echo "https://www.google.fr/search?q=%22" . $requete . "%22" . " : " . $nombreResultats . "<br>";
}
$n = 0;
while ($n <= strlen($nombreResultats)) {
if ($nombreResultats[$n] == "0" || $nombreResultats[$n] == "1" || $nombreResultats[$n] == "2" || $nombreResultats[$n] == "3" || $nombreResultats[$n] == "4" || $nombreResultats[$n] == "5" || $nombreResultats[$n] == "6" || $nombreResultats[$n] == "7" || $nombreResultats[$n] == "8" || $nombreResultats[$n] == "9") {
$nombreResultats2 = $nombreResultats2 . $nombreResultats[$n];
}
$n = $n + 1;
}
if (stripos($page, "Aucun") != false) {
$nombreResultats2 = "0";
echo "https://www.google.fr/search?q=%22" . $requete . "%22" . " : " . "Aucun résultat <br>";
}
return intval ($nombreResultats2);
}
if ($_POST["nom"]) {
$nom = $_POST["nom"];
$totalConcret = requete("un%20" . $nom);
$testConcret = requete("je%20vois%20un%20" . $nom) + requete("je%20sens%20un%20" . $nom) + requete("je%20touche%20un%20" . $nom) + requete("je%20goute%20un%20" . $nom) + requete("j'entends%20un%20" . $nom);
echo $totalConcret . "<br>";
echo $testConcret . "<br>";
if ($testConcret >= $totalConcret/500) {
echo "Ceci est un nom concret !";
}
else {
echo "Ceci est un nom abstrait !";
}
}
?>
</body>
</html>