Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>EDIT:</strong> In case i didn't read the question carefully, if you want to only get function parameters,you can see these example :</p> <pre><code>$content_file = 'function func_name($param_1=\'\',$param_2=\'\'){'; preg_match('/function func_name\((.*)\{/',$content_file,$match_case); print_r($match_case); </code></pre> <p>but if you want to manipulate the function, read below.</p> <hr> <p>How about these :</p> <ol> <li>read file using <code>file_get_contents();</code></li> <li>use <code>preg_match_all();</code> to get all function inside that file.</li> <li>please not that i write <code>/*[new_function]*/</code> inside that file to identify EOF.</li> </ol> <p>I use this to dynamically add/ delete function without have to open that php files. </p> <p>Practically, it should be like this :</p> <pre><code>//I use codeigniter read_file(); function to read the file. //$content_file = read_file('path_to/some_php_file.php'); //i dont know whether these line below will work. $content_file = file_get_content('path_to/some_php_file.php'); //get all function inside php file. preg_match_all('/function (.*)\(/',$content_file,$match_case); // //function name u want to get $search_f_name = 'some_function_name'; // for($i=0;$i&lt;count($match_case[1]);$i++){ if(trim($match_case[1][$i]) == $search_f_name){ break; } } //get end position by using next function start position if($i!=count($match_case[1])-1){ $next_function= $match_case[1][$i+1]; $get_end_pos = strripos($content_file,'function '.$next_function); } else { //Please not that i write /*[new_function]*/ at the end of my php file //before php closing tag ( ?&gt; ) to identify EOF. $get_end_pos = strripos($content_file,'/*[new_function]*/'); } //get start position $get_pos = strripos($content_file,'function '.$search_f_name); //get function string $func_string = substr($content_file,$get_pos,$get_end_pos-$get_pos); </code></pre> <p>you can do <code>echo $func_string;</code> to know whether these code is running well or not.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload