ちょっと、単語の表を作成し、表の単語に関連付けられた値を切り取ります。私はそれを持っている必要があるので、単語をクリックすると、単語の切り抜き情報が出力されます。これは、最終的に単語に関連付けられた情報です。問題は、 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