Kashyap Kotak
Kashyap Kotak

Reputation: 1938

Find the declaration of any variable in php file in a PHP project

This question is different from: Find declaration of a global variable in PHP as that question is asked specifically for Linux as the questioner has mentioned the use of grep, etc.

Actually, I want to contribute to phpMyAdmin. The code has many Global variables and I want to find where they were declared. I am using Windows.

Upvotes: 0

Views: 238

Answers (2)

Matt
Matt

Reputation: 754

There doesn't need to be any declaration in the global scope. The global $foo declarations that you see in the functions where $foo is used are sufficient. It can easily be the case that the global variable is only referenced from within these functions.

The following code works, for example:

function print_it() {
    global $my_global;
    echo $my_global;
}
function set_it() {
    global $my_global;
    $my_global = 17;
}
set_it();
print_it();  // echos 17

Upvotes: 0

kgrwhite
kgrwhite

Reputation: 106

Are you using an IDE? If so you could always do a project wide search for the specific variable.

Otherwise text editors like Notepad++ have a "Open folder as workspace" option. Doing this then running a search should help.

Upvotes: 2

Related Questions