Jump to content

return as specific location


hackalive

Recommended Posts

Hi guys so I have a PHP page with a function, now this function calls a HTML page and should return the contents to th exact spot where the cuntion is called, but it is returning it to the start of the document, any ideas how to fix this? (no iFrame suggestions please).

 

$A = str_replace('<A>', require_once($dir.'/'.$file), $A);
return $A;

is the contents of the function, and this does call the right file, just how do I get it to return in a specific location?

Link to comment
Share on other sites

if you want to get the contents of the HTML page then use

<?php
$page = file_get_contents($dir . '/' . $file);
$A = str_replace('<A>', $page, $A);
return $A;
?>

Is that what you wanted to do?

 

if you also want to write back to the html page then use file_put_contents()

Link to comment
Share on other sites

mm, i didnt think it would parse PHP. It might parse it from absolute URL's (like calling http://google.com or something) so you might try that. Otherwise i'm not entirely sure how you would do it. Is the PHP inside that file 100% needed?

 

EDIT:

Hmm, i was looking at file_get_contents and i found this little cURL function. You might also like to try it:

<?php
function curl_get_file_contents($URL)
    {
        $c = curl_init();
        curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($c, CURLOPT_URL, $URL);
        $contents = curl_exec($c);
        curl_close($c);

        if ($contents) return $contents;
            else return FALSE;
    }
?>

Link to comment
Share on other sites

okay what you suggested ignace works except..... now all the themeting etc is gone (it has replace <PL1> with the file but all the surrounding stuff for <PL1> which should stay is also gone.

 

I have

ob_start();
$A = str_replace('<A>', require_once($dir.'/'.$file), $A);
$A = ob_get_contents();
return $A;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.