1

HTMLページを生成し、各ページを保存するファイルを作成するcmsを作りたいです。

理想的には、次のようなものが必要です。

<?php
$file1 = get_produced_html_from('mainPage.php');
/* write the file to a directory*/


$file2 = get_produced_html_from('ProductsPage.php');
/* write the file to a directory*/
?>

require、include、require_once、include_onseなどの代わりに見逃した関数はありますか?

明確にするために: .php ファイル内に php コードは必要ありません。html コンテンツのみが必要です。つまり、php ファイルを最初に実行する必要があります。

解決策は、 http://domain.com/templates/mainPage.phpを HTML ストリームとして読み取ってhttp://php.net/manual/en/function.file-get-contents.phpを使用するようなものだと思いますか?

本当にありがとうございました。

4

2 に答える 2

1

cURL を使用して、レンダリングされた出力全体を URL から取得できます。

次のように使用できます。

// Initiate the curl session
$ch = curl_init();

// Set the URL
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/mypage.php');

// Allow the headers
curl_setopt($ch, CURLOPT_HEADER, true);

// Return the output instead of displaying it directly
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the curl session
$output = curl_exec($ch);

// Close the curl session
curl_close($ch);
于 2013-08-25T23:18:16.047 に答える