PHP:将包含数据分配给变量?
从逻辑上讲,这就是我想要实现的目标:PHP:将包含数据分配给变量?,php,include,strip-tags,Php,Include,Strip Tags,从逻辑上讲,这就是我想要实现的目标: $variable = include "file.html"; strip_tags($variable); 可能吗 如果没有,如何对要包含的文件内容运行strip_tags函数。我只想获取文件的文本内容,而不是html数据 希望我讲得通。您愿意做的是使用文件获取内容()而不是包含 例如: <?php $file = 'file.html'; $data_without_html_tags = strip_tags(file_get_conten
$variable = include "file.html";
strip_tags($variable);
希望我讲得通。您愿意做的是使用
文件获取内容
()而不是包含
例如:
<?php
$file = 'file.html';
$data_without_html_tags = strip_tags(file_get_contents($file));
?>
您可以使用file\u get\u contents
()而不是include
例如:
<?php
$file = 'file.html';
$data_without_html_tags = strip_tags(file_get_contents($file));
?>
通过缓冲缓存,您可以非常轻松地做到这一点:
ob_start();
include("whatever.html");
$whateverHtml = ob_get_clean();
更多关于输出控制的信息。通过缓冲缓存,您可以非常轻松地做到这一点:
ob_start();
include("whatever.html");
$whateverHtml = ob_get_clean();
更多关于输出控制