【发布时间】:2012-07-03 12:14:29
【问题描述】:
我有一个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");
?>
或者使用 function() 会更好,所以我可以传递某种变量
<?php
$variable = $_GET['r'];
echo output($variable);
?>
output.php
function output(variable){
//html and php
}
但是,我不太确定 HTML 是否可以在函数中使用?有什么建议吗?
谢谢
【问题讨论】:
标签: php function variables include require