[php] array

Résolu/Fermé
kiki67100 Messages postés 313 Date d'inscription samedi 6 mai 2006 Statut Membre Dernière intervention 10 août 2013 - 27 févr. 2007 à 09:55
P@ Messages postés 1709 Date d'inscription vendredi 7 juillet 2000 Statut Membre Dernière intervention 24 mars 2009 - 2 mars 2007 à 11:50
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
<?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:

8 réponses

kiki67100 Messages postés 313 Date d'inscription samedi 6 mai 2006 Statut Membre Dernière intervention 10 août 2013 19
27 févr. 2007 à 16:27
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
3
P@ Messages postés 1709 Date d'inscription vendredi 7 juillet 2000 Statut Membre Dernière intervention 24 mars 2009 185
27 févr. 2007 à 11:02
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
0
kiki67100 Messages postés 313 Date d'inscription samedi 6 mai 2006 Statut Membre Dernière intervention 10 août 2013 19
27 févr. 2007 à 12:33
jai amilorer le script mais
<?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

??
0
P@ Messages postés 1709 Date d'inscription vendredi 7 juillet 2000 Statut Membre Dernière intervention 24 mars 2009 185
27 févr. 2007 à 14:06
oui, parce que tu boucle sur i
essaie de tester avec in_array pour verrifier que $_SERVER['HTTP_USER_AGENT']
est dans $bot
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
kiki67100 Messages postés 313 Date d'inscription samedi 6 mai 2006 Statut Membre Dernière intervention 10 août 2013 19
27 févr. 2007 à 15:23
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>';
    }
}

?>
0
kiki67100 Messages postés 313 Date d'inscription samedi 6 mai 2006 Statut Membre Dernière intervention 10 août 2013 19
27 févr. 2007 à 16:29
Merciiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
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'; 
} 
?>
0
kiki67100 Messages postés 313 Date d'inscription samedi 6 mai 2006 Statut Membre Dernière intervention 10 août 2013 19
1 mars 2007 à 10:30
comme promie L'URL

https://codes-sources.commentcamarche.net/

encore merci
0
P@ Messages postés 1709 Date d'inscription vendredi 7 juillet 2000 Statut Membre Dernière intervention 24 mars 2009 185
2 mars 2007 à 11:50
de rien :D
0