Php WP插件中的嵌套函数

Php WP插件中的嵌套函数,php,wordpress,Php,Wordpress,我写了一个php代码来读取文本文件,它工作得很好,没有问题,看看这段代码 <?php function Read($filepath) { $myfile = fopen($filepath,"r") or die("Unable to open file!"); $label=fread($myfile,filesize($filepath)); fclose($myfile); echo $label; } ?> 现在,如果我尝试在下面的输入中使用Read函数,它可以正常工

我写了一个php代码来读取文本文件,它工作得很好,没有问题,看看这段代码

<?php
function Read($filepath)
{
$myfile = fopen($filepath,"r") or die("Unable to open file!");
$label=fread($myfile,filesize($filepath));
fclose($myfile);
echo $label;
}
?>

现在,如果我尝试在下面的输入中使用Read函数,它可以正常工作

<input type="text" id="txtname" name="txtname" placeholder="<?php Read("resources/name_ar.txt");?>" />
似乎“Read”函数找不到该文件。调用函数时,请尝试以下操作:

<?php Read(dirname(__FILE__) . "resources/name_ar.txt");?>

<?php Read(dirname(__FILE__) . "resources/name_ar.txt");?>