Problems including php in html

Problems including php in html

Posted by: EarlW
Posted on: 2007-07-04 08:01:00

I have several Dreamhost domains - and php works on all of them, so I shouldn't have to do anything to .htaccess. The following works in an shtml file:

<!--#include virtual="/full/path/tofile.php" -->

-which includes output of a php page on the same domain.

However, I want to be able to include that same output in an html file on another domain (under a different user account). None of the following work. Help?

<?php
$fileOutput=implode('',file('http://www.yoursite.com/full/path/tofile.php'));
?>

<?php
readfile("http://www.yoursite.com/full/path/tofile.php");
?>

<?php
include("http://www.yoursite.com/full/path/tofile.php");
?>

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.yoursite.com/full/path/tofile.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?>


Re: Problems including php in html

Posted by: anonymous2
Posted on: 2007-07-04 08:16:00

This helps?

http://wiki.dreamhost.com/KB_/_Unix_/_.htaccess_files#How_can_I_use_ssi_on_files_with_.html_extensions.3F

Re: Problems including php in html

Posted by: Atropos7
Posted on: 2007-07-04 08:19:00

DreamHost disabled allow_url_fopen in their install of PHP. This means you can not use URLs instead of path names.

See the DreamHost Wiki article on CURL for examples of doing different things. The code you posted does what it says - fetches the content. You'll need to do something with it once you have it, like save it to a file or output it to the browser.


cool openvein.org -//-

Re: Problems including php in html

Posted by: scjessey
Posted on: 2007-07-04 08:51:00

This may seem like I'm stating the blindingly obvious, but why not just copy the relevant files to the alternate user account so that you can use a regular include() function?

Tags: php in htmlphp worksdreamhosthtaccessshtml