WordPress.org

Ready to get started?Download WordPress

Forums

Can't access variables I just defined on the same page (2 posts)

  1. poopers
    Member
    Posted 6 years ago #

    aight, I'm using exec-php to enable php in my posts. I define a variable in my post...for example:

    <?php $hello = "sup"; ?>

    what I would like to be able to do is utilize $hello in my single post template. However, no matter how I've tried to access it, for example:

    <?php echo "$hello"; ?>
    <?php if (isset($hello)) { ?>

    ...I can't get the template to even acknowledge $hello is set. Anyone here know why, or what I should do about this?

  2. Kafkaesqui

    Posted 6 years ago #

    Initially:

    <?php global $hello; $hello = "sup"; ?>

    When using the var:

    <?php global $hello; echo "$hello"; ?>

    Reference:
    http://php.net/global

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags