dimanche 27 décembre 2020

PHP else/if statement, with rand() [duplicate]

I try to solve this exercise, but Im not sure how to look for the solution. For my current knowledge my program should print out smg, but I get only error .

Error message :

     
Warning: Undefined variable $x in /in/NVFqg on line 6
Charile bit your finger!

Here is my code :

<?php 
function isBitten()
{

if ($x <= 50) { // line 6 //
   echo "Charile bit your finger!"; 
   $x = rand(0, 100);
}

else {
  echo "Charlie did not bite your finger";
}



  }

 ?>



<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Charlie</title>
  </head>
  <body>


     <?php
     isBitten();
      ?>

  </body>
</html>

Your help is much appreciated! Thank you!

Aucun commentaire:

Enregistrer un commentaire