[php] array
Résolu
kiki67100
Messages postés
313
Date d'inscription
Statut
Membre
Dernière intervention
-
P@ Messages postés 1709 Date d'inscription Statut Membre Dernière intervention -
P@ Messages postés 1709 Date d'inscription Statut Membre Dernière intervention -
Bonjour a tous
voila je suis debutant en php ; jai fais un script antiaspirateur sans bdd
et voila que quand je definie les moteur de rechercher avec se code
il ya une error ligne 4 je comprend pas
voila je suis debutant en php ; jai fais un script antiaspirateur sans bdd
et voila que quand je definie les moteur de rechercher avec se code
<?php $bots=array('GoogleBot','MSNBot','Yahoo! Slurp','VoilaBot','ZyBorg','Fast Web Crawler',' appie'); $nb_bots=count($bots)-1; for($i=0;$i<=$nb_bots,$i++){ if(strstr($_SERVER['HTTP_USER_AGENT'], $bot[$i])){ echo '<br><br><br><h1>tu et un user agent</h1></br></br></br>'; }else{ echo '<br><br><br><h1>tu est bannie</h1></br></br></br>'; } } <?
il ya une error ligne 4 je comprend pas
A voir également:
- [php] array
- Easy php - Télécharger - Divers Web & Internet
- Expert php pinterest - Télécharger - Langages
- Retour a la ligne php - Forum Webmastering
- Alert php - Forum PHP
- Retour a la ligne php ✓ - Forum PHP
8 réponses
Merciiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
merci P@
sa marche super avec n_array sa donne sa
<code><?php
$bots = array("GoogleBot","MSNBot","Yahoo! Slurp","VoilaBot","ZyBorg","Fast Web Crawler"," appie","mozilla","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
$user = $_SERVER['HTTP_USER_AGENT'];
if (in_array($user, $bots))
{
echo 'ROBOT ';
}
else{
echo 'aspirateur te bannie';
}
?>code>
encore merci je te donnerais L'URL du code MAJ de phpcs
merci P@
sa marche super avec n_array sa donne sa
<code><?php
$bots = array("GoogleBot","MSNBot","Yahoo! Slurp","VoilaBot","ZyBorg","Fast Web Crawler"," appie","mozilla","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
$user = $_SERVER['HTTP_USER_AGENT'];
if (in_array($user, $bots))
{
echo 'ROBOT ';
}
else{
echo 'aspirateur te bannie';
}
?>code>
encore merci je te donnerais L'URL du code MAJ de phpcs
tu peux nous donner l'erreur en question
et pour info les <br> existe mais pas le </br>
mais ca ne devrait t'afficher d'erreur
et pour info les <br> existe mais pas le </br>
mais ca ne devrait t'afficher d'erreur
jai amilorer le script mais
mais sa me renvoie 7fois tu es banni
??
<?php $bots=array('googlebot','MSNBot','Yahoo! Slurp','VoilaBot','ZyBorg','Fast Web Crawler',' appie'); $nb_bots=count($bots)-1; for($i=0;$i<=$nb_bots;$i++){ if(strstr($_SERVER['HTTP_USER_AGENT'], $bots [$i])){ echo '<br><br><br><h1>tu et un user agent</h1>'; }else{ echo '<br><br><br><h1>tu est bannie</h1>; } } ?>
mais sa me renvoie 7fois tu es banni
??
oui, parce que tu boucle sur i
essaie de tester avec in_array pour verrifier que $_SERVER['HTTP_USER_AGENT']
est dans $bot
essaie de tester avec in_array pour verrifier que $_SERVER['HTTP_USER_AGENT']
est dans $bot
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Sa me revoie une page blanche jai bien fais comme sa
<?php $bots=in_array('GoogleBot','MSNBot','Yahoo! Slurp','VoilaBot','ZyBorg','Fast Web Crawler',' appie','mozilla'); $nb_bots=count($bots)-1; for($i=0;$i<=$nb_bots;$i++){ if(strstr($_SERVER['HTTP_USER_AGENT'], $bots[$i])){ echo '<br><br><br><h1>tu et un user agent</h1></br></br></br>'; }else{ echo '<br><br><br><h1>tu est bannie</h1></br></br></br>'; } } ?>
Merciiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
merci P@
merci P@
><?php $bots = array("GoogleBot","MSNBot","Yahoo! Slurp","VoilaBot","ZyBorg","Fast Web Crawler"," appie","mozilla","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"); $user = $_SERVER['HTTP_USER_AGENT']; if (in_array($user, $bots)) { echo 'ROBOT '; } else{ echo 'aspirateur te bannie'; } ?>