PHP - 检查函数是否包含

I want to check if a function contains a variable called $marker.

This is what I'm trying to do:

if(function('head') contains '$marker') {
     return true;
}

Is there any way to do this?

Ummm... it's not built into PHP, and, frankly, changing the files would be better, but for science reasons, I wrote a check for it. It fetches the filenames's contents every function call, so I'd recommend, if you use it more than once, to store the file's contents in another variable, but, nevertheless, this is will give you a functional view on how to do it:

<?php

function test() {   $marker;}

function negativeTest() {
    $noMarker;
}

function checkFunction($function, $variable, $filename) {
    $file = file_get_contents($filename);
    preg_match_all("/function\s+([a-z0-9_-]+)\s*\(.*?\)\s*\{((
|.)*?)\}/im",$file,$matches);
    for ($i = 0; $i < count($matches[1]); $i++) {
        if ($matches[1][$i] == $function && strpos($matches[2][$i], $variable) != false) {
            return true;
        }
    }
    return false;
}

echo checkFunction("test","\$marker","index.php");

?>