我有一个output.php
文件,它结合了HTML和PHP内容。
index.php 有
<?php
require("output.php");
?>
哪种方式是传递变量的更好方法?我应该
<?php
$variable = $_GET['r']; //this is some variable that will be passed into output.php
require("output.php");
?>
或者使用函数()会更好,所以我可以传递某种变量
<?php
$variable = $_GET['r'];
echo output($variable);
?>
output.php
function output(variable){
//html and php
}
但是,我不确定HTML是否可以在函数内部使用?有什么建议吗?
由于
答案 0 :(得分:0)
据我所知,使用功能方法更好。该函数可以在几个文件中使用。就Html而言,它可以支持没有这样的问题。我建议你使用功能方法。