我们如何从文件中读取php函数[关闭]

$dir = "dir";
foreach ($files as $file){ 

    $filename =  $dir . $files["9"]; 
    $handle = fopen(  $filename , 'r'
}

The files I am getting in the loop are php files. So how do I read functions of that class?

If what you want is to be able to use functions and classes from another PHP file, you have to include or require the file before you use the content of the files.

The difference between these two is, that require will through a fatal_compile_error if it was not able to find the file.

You can checkout the manual here.

Example code would be:

<?php
require('somefile.php');
?>

Hope this helps!