Support » How-To and Troubleshooting » Cannot pass variable with PHP

Cannot pass variable with PHP

  • I am trying to a pass a variable with PHP in my blog. Here is my code:

    define(‘WP_USE_THEMES’, false);
    <?php echo “‘$myvar'”;?>

    When I type “http://www.11thfloor.net/videos/test.php?myvar=test” into my address bar the variable does not pass. But when I remove

    define(‘WP_USE_THEMES’, false);

    from my code the variable passes.

    Can someone help with this?

Viewing 1 replies (of 1 total)
  • Moderator Samuel Wood (Otto)


    WordPress.org Tech Dude

    The reason this is happening is that you appearantly have register_globals turned on by default (since you think that $myvar will contain that information passed in via the URL).

    Since this is a massive security hole, WordPress turns that off and unsets all the variables that were set when you call the wp-blog-header.php.

    register_globals should always be OFF. It defaults to off in the latest PHP versions, and you should really edit your php.ini to turn it off as well.

    If you want the contents of myvar, the correct way to get them is to access it via $_GET[‘myvar’] or $_POST[‘myvar’], depending on how it was sent to your script.

Viewing 1 replies (of 1 total)
  • The topic ‘Cannot pass variable with PHP’ is closed to new replies.