Sufendy
Sufendy

Reputation: 1242

Find the definition of PHP Constant

I wish to know where (as in which php file) is a constant being defined. Do you know of any trick of getting this done fast?

Let's say that I'm not familiar with the whole system, but will need a quick fix on this constant. Browsing through each includes files is boring.

UPDATE I'm using notepad++ and accessing the files through FTP client (FileZilla).

Upvotes: 1

Views: 840

Answers (6)

TRiG
TRiG

Reputation: 10643

You need Agent Ransack. Well, really you need a proper IDE, but as a quick fix: download all PHP files and do a search for files containing text define AND CONSTANT. The built in search program on Windows is terrible, so use Agent Ransack instead.

Upvotes: 2

Herr
Herr

Reputation: 2735

I would recommend TextMate if your (hopefully) on a mac, if not, get Sublime 2 (beta).

Upvotes: 0

user744116
user744116

Reputation:

I don't know well what u want, but with define("CONST_NAME", "value") u define a const.

to check, you use this:

if(defined("CONST_NAME", "value")) { 
//const defined
} else {
//do anything
}

Upvotes: -2

Emil Vikström
Emil Vikström

Reputation: 91902

I usually just grep my way into Mordor:

grep -l 'define..CONSTANT' *

(Note: I always run Unix-like operating systems. I don't know about Windows, but most editors should support something similar).

Upvotes: 3

Stephen
Stephen

Reputation: 18917

use a mult-file search tool or an IDE with that feature, and search across the project directory for define('MY_CONST_NAME', where MY_CONST_NAME is the name of the constant you want to find.

Upvotes: 2

Muhammad Ummar
Muhammad Ummar

Reputation: 3631

What IDE you are using? If you are using Eclipse, then its quite easy.. just press Ctrl and click on the constant, it will take you to the line where this constant is defined..

Upvotes: 0

Related Questions