用于脚本生成函数调用的PHP路径
我有一个助手文件,基本上如下所示:用于脚本生成函数调用的PHP路径,php,dirname,Php,Dirname,我有一个助手文件,基本上如下所示: helper.php: <?php function renderPartial($name) { return file_get_contents(__DIR__.'/'.$name.'.php'); } helper.php: 您可以将当前的\uuuuu DIR\uuuu作为参数传递 function renderPartial($name, $dir) { return file_get_contents($dir.'/'
helper.php:
<?php
function renderPartial($name) {
return file_get_contents(__DIR__.'/'.$name.'.php');
}
helper.php:
您可以将当前的\uuuuu DIR\uuuu
作为参数传递
function renderPartial($name, $dir) {
return file_get_contents($dir.'/'.$name.'.php');
}
及
helper.php在哪个目录中?您应该执行包含或要求,而不是只读取.php`文件。。。这样,您就可以通过脚本发送变量。
function renderPartial($name, $dir) {
return file_get_contents($dir.'/'.$name.'.php');
}
<?= renderPartial('_form', __DIR__) ?>