Jump to content

[SOLVED] curl results


Lefu

Recommended Posts

Dear all,

 

I have this code:

$ch = curl_init();

$timeout = 0; // set to zero for no timeout

curl_setopt ($ch, CURLOPT_URL, 'http://localhost/example/urlinclude.php?contentid=3');

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

$file_contents = curl_exec($ch);

curl_close($ch);

echo $file_contents;

 

The results is

hello world' ?>
 

instead of

hello world

 

the code in urlinclude.php file is

$code = "echo '<h1>hello world</h1>' ";

echo "<? $code ?>";

 

I am fetching my code from the mysql db, I need to output the results on the screen.

allow_url_include=off

 

how can I achieve the results?

 

thanks a lot for your input.

Link to comment
https://forums.phpfreaks.com/topic/100403-solved-curl-results/
Share on other sites

this:

 

$code = "echo '<h1>hello world</h1>' ";
echo "<? $code ?>";

 

quite possible should be:

 

$code = "echo '<h1>hello world</h1>'; ";
echo '<?php $code ?>';

---------

 

so you want to grab a code from another server - and then execute it on yours? (dangerous but ah well):

 

look into eval() function - www.php.net/eval

 

Link to comment
https://forums.phpfreaks.com/topic/100403-solved-curl-results/#findComment-513476
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.