Page 1 of 1

Grabbing all variables and displaying on screen

Posted: Fri Nov 27, 2009 5:28 am
by tegwin
First of all hello! :mrgreen:

I am using a type of CMS system, you can call up various details from the front end on any page by using "tags" so [user_firstname], [user_e-mail] etc is automatically recognised in a text field and displays the data for the user logged in.

I have a list of a few of these variables that I can use within bits of PHP in the backend of the CMS to take the "tag" of the user logged in and pass it to a database etc...

I can generate a new one of these variable things by doing this (e.g. take some data from a datbase and pass it to a "variable" to be picked up by page:

Code: Select all

 
//Pass active variable to tag
$MyVariable = $some_variable;
setVar ("myvariablename", $MyVariable);
 
I know for a fact that there are a number of other similar variables available, but I dont know what their "tags" are. I DO NOT have access to the back end PHP code that generates them, and I CAN NOT ask the provider of the CMS for the remaining tags.

Is there any way in php code that I can call up all variables on a given page and list them so I can see what I have?

I have managed to do this:

Code: Select all

reset( $GLOBALS );
while( list( $name, $val ) = each( $GLOBALS )) {
    echo "$name: $val<BR>";
}
 
When I run it I get this:
GLOBALS: Array
_POST: Array
_GET: Array
_COOKIE: Array
_FILES: Array
_SERVER: Array
_REQUEST: Array
_ENV: Array
val: Array
name: val
How can I see what is actually in the variable arrays?

Once I know the tags that are available I can use them to build ontop of the CMS to make it do what I want it to do!

Help will be really appreciated im getting myself mightely confused over this!

Re: Grabbing all variables and displaying on screen

Posted: Fri Nov 27, 2009 5:45 am
by daedalus__
:)

get_defined_vars()

format with a pre block or something

use the php reference next time!

http://www.youtube.com/watch?v=qOlPAQ192V0

Re: Grabbing all variables and displaying on screen

Posted: Fri Nov 27, 2009 9:01 am
by tegwin
Agh thanks for that, spent hours searching this morning to no avail.. must have missed that one...

I can sort of get some of the variables to display but im struggling to get any of the "non surface level" ones to display.

Re: Grabbing all variables and displaying on screen

Posted: Fri Dec 04, 2009 5:12 am
by tegwin
Can anyone help with this?

if I do this

Code: Select all

<?php
print '<pre>' . htmlspecialchars(print_r(get_defined_vars(), true)) . '</pre>';
?>
 
I get a nice big list of stuff dumped from the code. Included in that is the [QUERY_STRING]
[QUERY_STRING] => domain=ZnZlcg%3D%3D&company_id=79&contact_id=7226&selected_contact_id=&document_id=136435&document_stack=a:1:{i:0;i:136435;}&user_var_page_name=get+defined+variable&user_var_page_description=&user_var_page_published_date=4th+December+2009&user_var_page_modified_date=4th+December+2009&user_var_page_created_by=john+smith&user_var_page_modified_by=john+smith&user_var_custom_icon=&frame_id=244892
The page URL is
The URL query string and the defined Vars QUERY STRING are not the same...

I want to use a single value from the query string above "user_id".. How can I pull out the single value from that string?

The non matching page URL is confusing me!

Sorry, I am sure this is a very simple question!

Re: Grabbing all variables and displaying on screen

Posted: Fri Dec 04, 2009 6:20 am
by daedalus__
$_GET['user_id']

?

o. 0

Re: Grabbing all variables and displaying on screen

Posted: Fri Dec 04, 2009 6:38 am
by tegwin
Doesnt $_get look at the URL query though? There is no "user_id" in the url string...

But there is in the query_string available from the server if that makes sence (using the get_defined_vars() function)


if I run

Code: Select all

<?php
 
echo $_get['user_id'];
 
?>
I get the sum total of nothing echo'd back to me!


I assume the real server query string is hidden from the user for security (thus the URL string is much smaller, see above post, ).... But I dont see how I can call something form the "non url" string?