if(isset())语句导致屏幕为空白

时间:2013-11-13 06:04:51

标签: php

嘿,我创建了一个单词表,并删除了与表中单词相关的值。我需要拥有它,所以当我点击一个单词时,它会打印出该单词的剪切信息,这最终是与该单词相关的信息。问题是,当我添加我的isset语句并刷新页面时,它只是一个空白的屏幕

这是我的完整代码

    <html>
<body>
<script>

  function wordCheck(chosenOne) {
     window.location="http://granite.sru.edu/~jaw1005/word.php?chosenOne=\"" + chosenOne + "\""

  }
</script>
<center>
<table id="test" border="1">
<?

$f="/homes/ddailey/public_html/threefull";
$o=file($f);
$rn=count($o);


for ($i=0;$i<3;$i++){
 print "<tr>";

    for ($g=0;$g<6;$g++){

      $lol=rand(1, $rn);
      $word= explode(" ", ltrim( $o[$lol], ' 0123456789'));
      $fullword = str_replace("\n", "&nbsp;", $o[$lol]);
      print "<td onClick='wordCheck(\"".$fullword."\")'>".ucfirst($word[0])."</td>";

   }
 print "</tr>";

}

if(isset($chosenOne)){
  $realWord=str_replace('"', "", $chosenOne);
  $wordSplit = explode(" ", $realWord);
  print ucfirst($wordSplit[2])."'s part of speech is: ".$wordSplit[3].", while its               frequency is:".$wordSplit[0];

?>
</table>
</center>
</body>
</html>

通过调试我已经确定这是引起问题的代码部分

   if(isset($chosenOne)){
      $realWord=str_replace('"', "", $chosenOne);
      $wordSplit = explode(" ", $realWord);
      print ucfirst($wordSplit[2])."'s part of speech is: ".$wordSplit[3].", while its               frequency is:".$wordSplit[0];

以下是指向http://granite.sru.edu/~jaw1005/word.php

页面的链接

1 个答案:

答案 0 :(得分:0)

您没有关闭大括号 }

if(isset($chosenOne)){
  $realWord=str_replace('"', "", $chosenOne);
  $wordSplit = explode(" ", $realWord);
  print ucfirst($wordSplit[2])."'s part of speech is: ".$wordSplit[3].", while its               frequency is:".$wordSplit[0];
}//<--- here
?>