1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Some php help over here please....

Discussion in 'PHP & Perl' started by glew, May 2, 2009.

  1. glew

    glew Junior Member

    Joined:
    Feb 10, 2008
    Messages:
    141
    Likes Received:
    93
    can someone show me the correct way to turn this into a variable!


    Code:
    <?php $posttags = get_the_tags(); 
    
    $count=0; if ($posttags) 
    
    { foreach($posttags as $tag) 
    
    { $count++; if (1 == $count) 
    
    { echo $tag->name . ' '; } } } ?>
    this was my last attempt but more errors :(

    Code:
    $box = '<?php' . $posttags . '= get_the_tags();
    
    ' . $count . '=0; if (' . $posttags . ') 
    
    { foreach(' . $posttags . 'as ' . $tag) 
    
    { $count++; if (1 == $count) 
    
    { echo $tag->name . '"\' \'; } } } ?>'
    i just can't figure out what to and what not to escape anytime I have a complex
    expression ie:
    Code:
    $box = <?php bloginfo(template_url) . /images/blank.jpg; ?>
    it's pissing me off! :banghead: any help would be appreciated!
     
  2. aReJay

    aReJay Power Member

    Joined:
    Apr 29, 2009
    Messages:
    736
    Likes Received:
    237
    Location:
    Down under
    Hmmm, can you tell us a little more about where the code has come from;
    get_the_tags() and bloginfo() are both custom functions, I assume associated with WP or someother OS software.

    aReJay
     
  3. _Austin

    _Austin Junior Member

    Joined:
    Apr 9, 2009
    Messages:
    147
    Likes Received:
    39
    Why do you need this stored as a variable?

    Another solution, if I'm on the right path here, is to just store this code into a separate PHP by it self and then just add "include( "path/phpfile.php" );" ( minus the outside "" ) where ever you need that code to execute.

    _Austin