2

I'm trying to get a variable dump in my php so I'm using:

print_r(get_defined_vars()); 

to produce it, but it results in a blank page no matter where I insert the code. Any ideas?

1
  • 1
    Is the code being reached? i.e. If you put print 'test'; afterwards, does it display test? Commented Jul 22, 2012 at 22:06

4 Answers 4

2

One of the outputted variables may contain HTML,CSS and/or JavaScript-code that prevents the site from being loaded.

Look at the source code (with Ctrl+U in most browsers, or right-click → View Source) instead of the rendered page to see everything that your php script outputs.

Also, make sure that the php code gets actually executed, by inserting an echo "test";. That should show up, at least in the source code.

Sign up to request clarification or add additional context in comments.

2 Comments

Nope, nothing on the page renders. Tried wrapping it in <pre> and no dice.
@JonLachonis It's not about rendering that's kind of the point of the answer. What URL are you looking at? It should start with view-source: in Chrome.
2

Well of course your code is correct, so the reason for the blank page must be that there is some error elsewhere (does the page work if you do NOT put that line in?); maybe your line breaks the syntax of a code block.

Then the error is redirected to php_errors.log or some other file, or maybe is not even generated, and you see a blank page.

Check:

  • to have error_reporting(E_ALL) in your script, at the earliest occasion
  • that the errors go where they should in php.ini
    • check those error log files (if any)
  • check server error logs (e.g. Apache's error_log file).

Once you've cleared the upstream error, you should be able to see your output.

Comments

2

get_defined_vars includes $GLOBALS among its returned variables, and print_r doesn't check for recursion. Therefore you are simply winding up in an infinite loop that not even max_execution_time can save you from.

Comments

0

Maybe If you are developing extension/plugin for a script that uses ioncube as protection, then maybe it is the issue, Ioncube seems to stop get_defined_vars() as a part of preventing reverse engineering.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.