我在 PHP 中的提交按钮上实现的操作未执行。一切正常,没有错误,但是当我单击按钮时没有任何反应。Notepad++ 看到该文件lines.php
已被修改。
<html>
<head>
<title>
Watch your Language
</title>
</head>
<body>
<H2 align="center">
<form method="post">
<input type="submit" onclick="English()" name="introdu" value="Choose english">
</form>
<a href="index.php">Home</a> | <a href="bot.php">Talk to robot</a>
</h2>
</body>
</html>
<script type="text/javascript">
function English()
{<?php
$myFile = "lines.php";
$fh = fopen($myFile, 'w');
$eng = <<<TEST
<?php
class TextToSpeech {
public $mp3data;
function __construct($text="") {
$text = trim($text);
if(!empty($text)) {
$text = urlencode($text);
$lang_en="http://translate.google.com/translate_tts?tl=en&q=\{$text}";
$lang_ro="http://translate.google.com/translate_tts?tl=ro&q=\{$text}";
$lang_fr="http://translate.google.com/translate_tts?tl=fr&q=\{$text}";
$language=$lang_en;
$this->mp3data = file_get_contents($language);
}
}
function setText($text) {
$text = trim($text);
if(!empty($text)) {
$text = urlencode($text);
$en="http://translate.google.com/translate_tts?tl=en&q=\{$text}";
$ro="http://translate.google.com/translate_tts?tl=ro&q=\{$text}";
$fr="http://translate.google.com/translate_tts?tl=fr&q=\{$text}";
$lang=$en;
$this->mp3data = file_get_contents($lang);
return $this->mp3data;
} else { return false; }
}
function saveToFile($filename) {
$filename = trim($filename);
if(!empty($filename)) {
return file_put_contents($filename,$this->mp3data);
} else { return false; }
}
}
?>
TEST;
echo $eng;
fwrite($fh, $eng);
fclose($fh);
?>
alert("File created");
}
</script>