Reputation: 3969
Let's say i have this php function called from multiple php files
do_something($var);
How can i find the files from which the function is called?
later edit: i want to do this on windows
Upvotes: 3
Views: 1063
Reputation: 8045
Three ways to do this:
Use a sensible directory structure and application design. If you're following OOD and have a clearly laid out directory structure, then it should be very easy to find the declaration for any class and its methods. If the method was declared in a parent class, you just scan up the inheritance tree. If, OTOH, you're writing spaghetti code and using tons of global functions, well... you've got bigger problems.
Consult the documentation. Any sizable application should have a well-documented API, which at minimum should include a list of all classes and their member functions and attributes. The API documentation should also tell you the file that each class is defined in. A quick search in the API would thus turn up the info you need.
Use an intelligent IDE like Eclipse that parses your code and class definitions. Eclipse has an Open Declaration function that will open up the source file where the element was declared and display the declaration.
You should always be doing the first two; the last is just a convenience.
Upvotes: 3
Reputation: 18570
At least some IDE's have a means of searching through your current project for all instances of certain variables, function calls, etc. If you are using an IDE, check its help.
If you are using a *nix system, you can use grep to search:
grep do_something *.php'
The above will search your current working directory for the text 'do_something' in all files ending with the '.php' extension. You can expand this to search all subdirectories of the current directory using the find command:
find . -name "*.php" -exec grep do_something {} \;
Use 'man grep' and 'man find' from your *nix command line to learn more.
If you are on Windows, I believe the find command can do similar things, I am not as familiar with it, but the basic syntax should look something like:
find "do_something" *.php
Upvotes: 3
Reputation: 6485
Adobe Dreamweaver has a site wide/directory text search function as does eclipse workbench, UltraEdit and TopStyle Pro.
Upvotes: 0