嘿,我创建了一个单词表并删除了与表中单词相关的值。 我需要它,所以当我点击一个单词时,它会打印出该单词的剪切信息,这最终是与该单词相关的信息。 问题是当我添加 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", " ", $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
您没有关闭大括号}
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
?>