How can find var is used in file require / include ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hitmanmx
Forum Newbie
Posts: 13
Joined: Mon Dec 22, 2008 1:29 am

How can find var is used in file require / include ?

Post by hitmanmx »

ex:
a.php

Code: Select all

 
$a = 1;
$b = 2;
 
b.php

Code: Select all

 
require('a.php')
//How can find var is used in file require / include ?
 
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: How can find var is used in file require / include ?

Post by andyhoneycutt »

I'm pretty sure you're looking for the get_defined_vars function. It returns an associative array of all defined variables.

-Andy
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: How can find var is used in file require / include ?

Post by Mark Baker »

The way to find if a particular variable (e.g. $a) is used in a particular included file (e.g. file1.php) is to open that file in a text editor and search for $a.
Of course, if you're using variable variables, then you won't find it.
hitmanmx
Forum Newbie
Posts: 13
Joined: Mon Dec 22, 2008 1:29 am

Re: How can find var is used in file require / include ?

Post by hitmanmx »

andyhoneycutt wrote:I'm pretty sure you're looking for the get_defined_vars function. It returns an associative array of all defined variables.

-Andy
Mark Baker wrote:The way to find if a particular variable (e.g. $a) is used in a particular included file (e.g. file1.php) is to open that file in a text editor and search for $a.
Of course, if you're using variable variables, then you won't find it.
i think fopen and search string too hard.
thk all for help
Post Reply