加载后如何解析当前PHP文件?

加载后如何解析当前PHP文件?,php,parsing,simple-html-dom,Php,Parsing,Simple Html Dom,我有一个php页面,它接收POST属性。然后根据这些属性呈现该页面。我想在从收到的属性中完全填充php页面之后,获取该页面的源代码。经过php解析器解析后,此页面将成为普通的html代码。我提到了文件\u get\u内容和PHP简单HTML DOM解析器,但找不到任何可接受的答案 我想要的是解析后的原始html代码,即PHP解析器 示例 echo "<p>Hi<p>" echo”Hi“ 页面将返回 <p>Hi</p> 你好 我希望这个输出如

我有一个
php
页面,它接收
POST
属性。然后根据这些属性呈现该页面。我想在从收到的属性中完全填充
php
页面之后,获取该页面的源代码。经过
php
解析器解析后,此页面将成为普通的
html
代码。我提到了
文件\u get\u内容
PHP简单HTML DOM解析器
,但找不到任何可接受的答案

我想要的是解析后的原始html代码,即
PHP解析器

示例

echo "<p>Hi<p>"
echo”Hi“
页面将返回

<p>Hi</p>
你好

我希望这个输出如上所述。

您需要使用PHP来获得PHP生成的输出

示例:

<?php

// From here on, keep all output in a buffer
ob_start();

// Output whatever you want
echo "<h1>Hello World!</h1>" . PHP_EOL;
echo "<p>How're you doin' today?</p>";

// Store the contents of the buffer in $output
$output = ob_get_contents();

// Clear the buffer and stop buffering the output
ob_end_clean();

// Show the output we caught using the buffer
var_dump($output);

?>
string(52) "<h1>Hello World!</h1>
<p>How're you doin' today?</p>"
您需要使用PHP获取PHP生成的输出

示例:

<?php

// From here on, keep all output in a buffer
ob_start();

// Output whatever you want
echo "<h1>Hello World!</h1>" . PHP_EOL;
echo "<p>How're you doin' today?</p>";

// Store the contents of the buffer in $output
$output = ob_get_contents();

// Clear the buffer and stop buffering the output
ob_end_clean();

// Show the output we caught using the buffer
var_dump($output);

?>
string(52) "<h1>Hello World!</h1>
<p>How're you doin' today?</p>"
您需要使用PHP获取PHP生成的输出

示例:

<?php

// From here on, keep all output in a buffer
ob_start();

// Output whatever you want
echo "<h1>Hello World!</h1>" . PHP_EOL;
echo "<p>How're you doin' today?</p>";

// Store the contents of the buffer in $output
$output = ob_get_contents();

// Clear the buffer and stop buffering the output
ob_end_clean();

// Show the output we caught using the buffer
var_dump($output);

?>
string(52) "<h1>Hello World!</h1>
<p>How're you doin' today?</p>"
您需要使用PHP获取PHP生成的输出

示例:

<?php

// From here on, keep all output in a buffer
ob_start();

// Output whatever you want
echo "<h1>Hello World!</h1>" . PHP_EOL;
echo "<p>How're you doin' today?</p>";

// Store the contents of the buffer in $output
$output = ob_get_contents();

// Clear the buffer and stop buffering the output
ob_end_clean();

// Show the output we caught using the buffer
var_dump($output);

?>
string(52) "<h1>Hello World!</h1>
<p>How're you doin' today?</p>"

您需要使用POST方法并提供POST参数来配置以下选项:

<?php
// Create a stream
$opts = array(
  'http'=>array(
    'method'=>"POST",
    'header'=>"Accept-language: en\r\n" .
              "Cookie: foo=bar\r\n"
  )
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.example.com/', false, $context);
?>


Curl也可能是一个很好的选项…

您需要使用POST方法配置以下选项,并提供POST参数:

<?php
// Create a stream
$opts = array(
  'http'=>array(
    'method'=>"POST",
    'header'=>"Accept-language: en\r\n" .
              "Cookie: foo=bar\r\n"
  )
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.example.com/', false, $context);
?>


Curl也可能是一个很好的选项…

您需要使用POST方法配置以下选项,并提供POST参数:

<?php
// Create a stream
$opts = array(
  'http'=>array(
    'method'=>"POST",
    'header'=>"Accept-language: en\r\n" .
              "Cookie: foo=bar\r\n"
  )
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.example.com/', false, $context);
?>


Curl也可能是一个很好的选项…

您需要使用POST方法配置以下选项,并提供POST参数:

<?php
// Create a stream
$opts = array(
  'http'=>array(
    'method'=>"POST",
    'header'=>"Accept-language: en\r\n" .
              "Cookie: foo=bar\r\n"
  )
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.example.com/', false, $context);
?>


Curl可能是一个很好的选择,而且…

带有输出缓冲的HTML特殊字符:

<?php
ob_start();
echo "<h1>Heading</h1><br>\n";
echo "<p>Randomsampletext</p>";
$output = ob_get_contents();
ob_end_clean();

带有输出缓冲的HTML特殊字符:

<?php
ob_start();
echo "<h1>Heading</h1><br>\n";
echo "<p>Randomsampletext</p>";
$output = ob_get_contents();
ob_end_clean();

带有输出缓冲的HTML特殊字符:

<?php
ob_start();
echo "<h1>Heading</h1><br>\n";
echo "<p>Randomsampletext</p>";
$output = ob_get_contents();
ob_end_clean();

带有输出缓冲的HTML特殊字符:

<?php
ob_start();
echo "<h1>Heading</h1><br>\n";
echo "<p>Randomsampletext</p>";
$output = ob_get_contents();
ob_end_clean();


我想到了,但我不完全理解您想要原始php源代码(
)的问题?或者该php代码的输出(
foo
)?请参阅更新的问题@DagonSee更新的问题@MarcBhtmlspecialchars,带有输出缓冲区应该足够了。我想到了,但我不完全理解您想要原始php源代码(
)的问题?或者该php代码的输出(
foo
)?请参阅更新的问题@DagonSee更新的问题@MarcBhtmlspecialchars,带有输出缓冲区应该足够了。我想到了,但我不完全理解您想要原始php源代码(
)的问题?或者该php代码的输出(
foo
)?请参阅更新的问题@DagonSee更新的问题@MarcBhtmlspecialchars,带有输出缓冲区应该足够了。我想到了,但我不完全理解您想要原始php源代码(
)的问题?或者php代码的输出(
foo
)?请参阅updated question@DagonSee updated question@MarcBhtmlspecialchars和输出缓冲应该足够了。将\n保留在那里也会在源代码中显示为新行。将\n保留在那里也会在源代码中显示为新行。将\n保留在那里也会在源代码中显示为新行好的。将\n保留在那里也会在源代码中显示为新行。