SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to Show variables

    I used this function to output all the variables on my page
    Code:
    <?php var_dump(get_defined_vars()); ?>
    I got a bunch of code strings eg:
    ["post_excerpt"]

    I have tried to output these values like this:
    Code:
    <?php echo $post_excerpt; ?>
    but they don't show.

    I am really just trying to find out what variables are available to me to use. I have plugins that are showing information on the page so I imagine there are quite a few I can use.

    How do I show what variables are available to me cleanly? Thanks

  2. #2
    SitePoint Enthusiast mithra62's Avatar
    Join Date
    Nov 2004
    Location
    Van Nuys
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like you're trying to do some wordpress hacking. If that's the case, and without knowing more, it could be that you're not doing the echo'ing inside the loop.

    That being said, can you offer more details about what your issue is?

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,714
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    If you are within a function, you may need to use the global declaration to access them.

    The get_defined_vars page has some code from one of the comment posters to find out all the variables in current scope and their values
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes it is wordpress "hacking" I am trying to find out what variables are available as I want to output the comments total for the posts.
    I am just looking for some simple code that does the same as the colfusion function cfdump. As far as echoing how do I loop throught htis variable?
    <?php echo $post_excerpt; ?>
    is that not correct? Thank you

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,714
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Bayliss Trevor View Post
    Yes it is wordpress "hacking" I am trying to find out what variables are available as I want to output the comments total for the posts.
    That is where reading the documentation becomes useful.
    For example: Function Reference/wp count posts

    If there's anything that you can't find, then the Wordpress Forums are the place to get more info about Wordpress.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  6. #6
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Paul appreciated!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •