我的PHP代码给出了错误,为什么?

时间:2018-01-10 02:37:46

标签: php

<?php 

  switch($_GET['select1']) {    
     $forecast = file_get_contents("https://www.astrospeak.com/horoscope/taurus");
     //error appears here when I am assigning forecast page a value else the code was 
     //working fine for simple switch statements.
        case 1:
            echo $forecast;
            break;
        case 2:
              echo '<div id="msg">Taurus, You have a bright luck today <br>';
            break;
         case 3:
             echo '<div id="msg"> Gemini, You have a bright luck today <br>';
            break;
        case 4:
             echo '<div id="msg"> You have a bright luck today <br>';
            break;  
         case 5:
             echo '<div id="msg"> You have a bright luck today <br>';
            break;
        case 6:
             echo '<div id="msg"> You have a bright luck today <br>';
            break;  
         case 7:
              echo '<div id="msg"> You have a bright luck today <br>';
            break;
        case 8:
              echo '<div id="msg"> You have a bright luck today <br>';
            break;
         case 9:
              echo '<div id="msg"> You have a bright luck today <br>';
            break;
        case 10:
             echo '<div id="msg"> You have a bright luck today <br>';
            break;  
             case 11:
             echo '<div id="msg"> You have a bright luck today <br>';
            break;
        case 12:
             echo '<div id="msg"> You have a bright luck today <br>';
            break;
        default:
           echo '<div id="msg">Bad Choice <br>';
            break;

    }
?>
<html>
 <div class="options">
    <form method="get" action="?" >
      <select name="select1">
          <option value="1">Aries</option>
          <option value="2">Taurus</option>
          <option value="3">Gemini</option>
          <option value="4">Aries</option>
           <option value="5">Cancer</option>
           <option value="6">Virgo</option>
           <option value="7">Libra</option>
           <option value="8">Scorpio</option>
           <option value="9">Sagittarius</option>
           <option value="10">Capricorn</option>
          <option value="11">Aquarius</option>
          <option value="12">Pises</option>
       </select>
      <input type="submit"  value="Go"\>
    </form>
  </div>    
</html>

1 个答案:

答案 0 :(得分:1)

switch语句之前或case 1内移动switch。无法在case和{{1}}

之间添加