SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Setting variable to file contents

    This is a bit odd, but I need something to do the following:

    Code PHP:
    //something to do the following without echoing it yet
    $var .= //contents of file.php;
     
    // following doesn't work because it echoes it right away
    $var .= include 'file.php';

    I need $var to be updated without actually including file.php because that would echo the contents of file.php.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Give this a whirl:

    PHP Code:
    ob_start();
    include(
    'file.php');
    $var .= ob_get_contents();
    ob_end_clean(); 


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
  •