PHP 来自 HTML 输入表单的输出

PHP output from HTML input Form

让用户在表单文本框中输入一个值,该文本框获取该值并将其放入 $html = file_get_html(' ') 并在页面上回显输出值。

<form action="dex.php" method="POST">
<b>Site:</b><input type="text" name="site" />
<input type="submit" name="submit" value="Search" />
</form>  

<?php
include('simple_html_dom.php');

$html = str_get_html('site');
echo htmlspecialchars($_POST['site']);
$html->find('div', 1)->class = 'bar';
$html->find('div[id=site]', 0)->innertext = 'foo';
//echo $html; here doesn't show webpage just results
$html = file_get_html('http://www.myrobotbuddy.com');
//$html - file_get_html(' '); from form input
echo file_get_html('$html')->plaintext;
echo $html; //shows website also 
?>

我只是在猜测你想要实现什么,但是:

首先将表单输入到一个变量中:

if (isset($_POST['submit'])) {
    $site = htmlspecialchars($_POST['site']);
}

然后:

if(isset($site)){
    $html = str_get_html($site);
}