開発環境
- OS X Lion - Apple(OS)
- Apache (Web Server)
- PHP (サーバーサイドプログラミング言語)
- TextWrangler(Text Editor) (BBEditの無料機能制限版、light版)
『初めてのPHP5』 (David Sklar 著、 桑村 潤 翻訳、 廣川 類 翻訳、 オライリー・ジャパン、2005年、ISBN978-4-87311-257-2)の10章(ファイルの操作)10.9(演習問題)1を解いてみる。
1.
PHPインタプリンタで読み込むHTMLファイル
<html>
<head>
<meta charset="utf-8" />
<title>{page_title}</title>
</head>
<body bgcolor="{color}">
<h1>Hello, {lang}</h1>
</body>
</html>
phpのコード
<?php
$page = file_get_contents("sample66.html");
$page = str_replace("{page_title}", "MyPage", $page);
$page = str_replace("{color}", "red", $page);
$page = str_replace("{lang}", "PHP", $page);
print $page;
?>
0 コメント:
コメントを投稿