SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2010
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting current source code into a variable

    Hi all,

    I'm having a bit of a headache with this... I have a page that is dynamically generated by a PHP Code. It is a personalised astrology report. I am trying to add the ability to download the page as a PDF File. I am trying to use something called DOMPDF but my first hurdle is getting the current page's source code into a variable.

    I have tried using file_get_contents() but it always returns blank! I assume that is because the page is dynamically created.

    Is there a way I can get the HTML Source Code of the current page AFTER it has rendered and then store it into a variable which I can then pass through a form to my dompdf script...

    for example, this is what I have so far:

    PHP Code:
    <?php $pdfhtml file_get_contents(); ?>
    <form action="pdfscript.php" method="post" name="pdf">
    <input type="hidden" name="html" value="<?php echo $pdfhtml?>" />
    <input type="submit" value="Download" />
    </form>
    And then my pdfscript.php file is fetching the "html" value like this:

    PHP Code:
    $html $_POST['name'];
    echo 
    $html
    But it is always blank!

    Help Please????

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    file_get_contents needs to know what file... to get the contents of....

    file_get_contents('somefile.php');
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


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
  •