<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
   <title>Web学習手帳</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/" />
   <link rel="self" type="application/atom+xml" href="http://agorian.com/help/web/atom.xml" />
   <id>tag:agorian.com,2009:/help/web//9</id>
   <updated>2009-03-27T16:13:35Z</updated>
   <subtitle>To Know To Think To Love</subtitle>
   <generator uri="http://www.sixapart.com/movabletype/">Movable Type 3.35</generator>

<entry>
   <title>外部からくる変数</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/phpscript/external-var.php" />
   <id>tag:agorian.com,2009:/help/web//9.492</id>
   
   <published>2009-03-27T14:32:44Z</published>
   <updated>2009-03-27T16:13:35Z</updated>
   
   <summary><![CDATA[&clubs;HTMLフォーム &lt;form action="foo.php...]]></summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="PHP" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[<h3 class="php">&clubs;HTMLフォーム</h3>
<pre class="phpcode">
&lt;form action="foo.php" method="post"&gt;
    名前:  &lt;input type="text" name="username" /&gt;
    メール: &lt;input type="text" name="email" /&gt;
    &lt;input type="submit" name="submit" value="送信" /&gt;
&lt;/form&gt;
&lt;?php
   echo $_POST['username']; echo $_POST['email'];
   echo $_REQUEST['username']; echo $_REQUEST['email'];  
?&gt;</pre>
<br>
〔例１〕foo.phpが本ページのとき<br>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    名前:  <input type="text" name="username" />　
    メール: <input type="text" name="email" />　
    <input type="submit" name="submit" value="送信" />
</form>

<pre class="sample">
<?php
   echo $_POST['username']."　";echo $_POST['email']."<br>";
   echo $_REQUEST['username']."　"; echo $_REQUEST['email']; 
?></pre>
]]>
      <![CDATA[〔例２〕
<pre class="phpcode">&lt;?php
if ($_POST) {
    echo '&lt;pre&gt;';
    echo htmlspecialchars(print_r($_POST, true));
    echo '&lt;/pre&gt;';
}
?&gt;</pre>
<pre class="sample">
<?php
if ($_POST) {
    echo '<pre>';
    echo htmlspecialchars(print_r($_POST, true));
    echo '</pre>';
}
?></pre>

<h3 class="php">&clubs;GETフォーム</h3>
<p>$_GET['～']に値が代入される。またGETは、QUERY_STRING (URLの'?'の後の情報)にも代入される。たとえば、 http://www.example.com/test.php?key=parameter のparameterは、 $_GET['key']に代入される。
<p>〔例〕echo $_GET['key'};</p>
<pre class="sample"><?php echo htmlspecialchars($_GET['key'],UTF-8); ?></pre>

]]>
   </content>
</entry>
<entry>
   <title>require()とinclude()</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/phpscript/requireinclude.php" />
   <id>tag:agorian.com,2009:/help/web//9.491</id>
   
   <published>2009-03-27T08:26:51Z</published>
   <updated>2009-03-27T12:48:16Z</updated>
   
   <summary>　本格的なWebアプリケーションを作る場合、定型的な処理を1つのファイルにして、...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="PHP" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[<p>　本格的なWebアプリケーションを作る場合、定型的な処理を1つのファイルにして、必要なところでrequire(
)またはinclude( )で読み込むと便利である。これを活用して、開発の効率やメンテナンス性を向上させることができる。<br>
<br>　require( )は処理中に1回だけ読み込まれる。ループの中で読み込むファイル名を変える時などは、include( )を使用する。またrequire( )やinclude( )はローカルにあるファイルだけでなく、リモートにあるファイルもURLを指定して読み込むことができる。<br>
<br>
</p>
<h4 style="font-family: Verdana; font-size: 10pt; color: white; background-color: rgb(143, 174, 190); padding-top: 1px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; ">【例１】　ページの先頭にメニューバー(topmenu.php)を組み込む</h4>
<blockquote><font color="navy">&lt;?php<br>&nbsp;&nbsp;require ("topmenu.php");<br>
?&gt;<br>
</font></blockquote>
<h4 style="font-family: Verdana; font-size: 10pt; color: white; background-color: rgb(143, 174, 190); padding-top: 1px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; ">【例２】　ループ処理の中で異なるファイルを複数読み込む</h4>
<blockquote><font color="navy">$mem = array ('one.htm', 'two.htm', 'three.htm');<br>for ($i=0; $i&lt;count($mem); $i++) {<br>　　include $mem[$i];<br>}</font></blockquote>

]]>
      
   </content>
</entry>
<entry>
   <title>PHPカウンター</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/phpscript/php-counter.php" />
   <id>tag:agorian.com,2009:/help/web//9.490</id>
   
   <published>2009-03-27T03:28:27Z</published>
   <updated>2009-03-27T08:12:10Z</updated>
   
   <summary>PerlやJavascriptで書かれた無料のアクセスカウンタがたくさんある。こ...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="PHP" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[<p>PerlやJavascriptで書かれた無料のアクセスカウンタがたくさんある。ここでは学習メモにとどめる。
→<a target="_blank" href="http://elmblog.com/script/counter/index.php">２００５年に作ったサンプル</a>
<p>つぎのカウンタ表示は設定不要のシンプルなPHPサンプル。軽いので携帯サイトに向いている。同一ホストの連続アクセスはカウントしない。<br>
<p style="color:blue;">あなたは<span style="color:red">
<?php include("http://elmblog.com/script/counter/scount.php");?></span>人目の訪問者です。 </p>
]]>
      <![CDATA[<span style="color:blue;">訪問者数：
<?php include("http://elmblog.com/script/counter/visitors2.php");?><br>
アクセス数：
<?php include("http://elmblog.com/script/counter/pageview2.php");?></span></p>
<div class="box">
<ul>
  <li>pcounter.phpを目的の表示形式に書き換える。
  <li>カウンターを表示したい部分につぎのように記述する。 <br>
  <span class="blue">&lt;?include(&quot;./pcounter/visitors.php&quot;);?&gt;</span><br>
  <br>
  <li>カウンターを表示したいページと同じディレクトリに、pcounterフォルダを転送し、パーミッションを下記のように設定する。
  <li>【ディレクトリ構成とパーミッション】<br>
  　tools.php　カウンターを表示するページ<br>
  　pcounter　カウンターフォルダ<br>
  　+ visitors.php [705]　訪問者数をカウント<br>
  　+ visitors.txt [606]　訪問者数を記録<br>
  　+ images [707]<br>
  　　+ 0.gif　～　9.gif　カウンター（画像好きな画像を格納）<br>
</ul>
</div>

<p>カウンターの無料レンタルもある。勉強し始めた頃は仕組みを理解するためにbravenetやcandyboxのカウンターを試用した。大手サービスプロバイダーにブログを開設していれば基本料金の範囲でカウンターが利用できる。　<a href="http://elmblog.com/script/counter/sample_lolipop.html">sample</a></p>]]>
   </content>
</entry>
<entry>
   <title>PHP認証</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/phpscript/php-authorize.php" />
   <id>tag:agorian.com,2009:/help/web//9.489</id>
   
   <published>2009-03-27T02:50:17Z</published>
   <updated>2009-03-27T06:02:21Z</updated>
   
   <summary>HTTPサーバ認証 このコードを書いたページにアクセスしようとするとサーバが認証...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="PHP" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[<h3 class="hdr">HTTPサーバ認証</h3>
<p>このコードを書いたページにアクセスしようとするとサーバが認証のためのポップアップ画面を表示する。ブラウザのポップアップを許可する必要がある。ユーザ名とパスワードを入力して認証する。いったん認証されるとブラウザを閉じるまで有効である。共有パソコンの場合は、最後にブラウザを閉じて認証をリセットしておく。サーバ管理者はcPanelのPassword Protect Directoriesでも設定できる。
]]>
      <![CDATA[<pre class="source">&lt;?php
$user_file = &quot;./user&quot;;
if(!isset($_SERVER['PHP_AUTH_USER'])){
  header(&quot;WWW-Authenticate: Basic realm=\&quot;ユーザ名とパスワードを入力してください。\&quot;&quot;);
  header(&quot;HTTP/1.0 401 Unauthorized&quot;);
  exit;
  }else{
  $id_pass = file($user_file);
  $flag = 0;
  for($i=0; $i&lt;count($id_pass); $i++){
    list($id,$pass) = split(&quot;,&quot;, $id_pass[$i]);
    if($id == $_SERVER['PHP_AUTH_USER'] &amp;&amp; $pass == $_SERVER['PHP_AUTH_PW']){
      $flag++;
      break;
    }
  }
}
?&gt;</pre>
<ul>
<li>認証に使うユーザ名とパスワードは、コンマ( , )で区切って、userファイルに書く。
<li>複数の組み合わせを設定できる。最後はかならず改行する。
<li>ユーザ名とパスワードが一致すると、$flagが1になるので、<br>
if($p_flag > 0){～} と判定して～に認証後の処理を書く。
<li><a target="_blank" href="http://elmblog.com/script/authorize/authorize.php">Sample</a> ユーザ名test パスワード1234を入力すると認証される。
</ul>
<h3 class="hdr">FORMを使った認証</h3>
<p>Formのname="action"を参照するとき、PHP4では$actionだったが、PHP5では$_POST['action']とする。$PHP_SELFも使えないので、$_SERVER['PHP_SELF']と書く。</p>

<h3>〔例〕ユーザ名test　パスワード1234</h3>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="action" value="post">
<p>ユーザ名：<input type="type" name="u_id" size="12">
パスワード：<input type="type" name="passwd" size="12">
<input type="submit" name="submit" value="送信">
</p>
<?php
$data_file = "./data"; 
$action = $_POST['action'];
$u_id = $_POST['u_id'];
$passwd = $_POST['passwd'];

if ($action == "post") {
 $p_data = file($data_file);
 $p_flag = 0;
 for($i=0; $i<count($p_data); $i++){
  list($id,$pass) = split(",", $p_data[$i]);
  if($id == $u_id && $pass == $passwd){
   $p_flag++;
  }
 }
  if($p_flag > 0){
  echo "<p style='color:red;'>正式に認証されました。</p>\n";
 } else {
  echo "<p style='color:red;'>認証できません。再入力してください。</p>\n";
 }
}
?>

<pre class="source">&lt;form action=&quot;&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;&quot; method=&quot;POST&quot;
enctype=&quot;application/x-www-form-urlencoded&quot;&gt; 
&lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;post&quot;&gt; 
ユーザ名：&lt;input type=&quot;type&quot; name=&quot;u_id&quot; size=&quot;12&quot;&gt;
パスワード：&lt;input type=&quot;type&quot; name=&quot;passwd&quot; size=&quot;12&quot;&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;送信&quot;&gt;
&lt;BR&gt; 
&lt;?php $data_file = &quot;./data&quot;; $action = $_POST['action'];
$u_id = $_POST['u_id']; 
$passwd = $_POST['passwd']; 
if ($action == &quot;post&quot;)
{ $p_data = file($data_file);
  $p_flag = 0;
  for($i=0; $i&lt;count($p_data);$i++){
  list($id,$pass) = split(&quot;,&quot;, $p_data[$i]);
  if($id == $u_id &amp;&amp; $pass == $passwd){
  $p_flag++; } }
  if($p_flag &gt; 0){ echo &quot;&lt;p style='color:red'&gt;正式に認証されました。&lt;/p&gt;\n&quot;; }
  else { echo &quot;&lt;p style='color:red;'&gt;認証できません。再入力してください。&lt;/p&gt;\n&quot;; }
} ?&gt; </pre>
]]>
   </content>
</entry>
<entry>
   <title>PHP事始め</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/phpscript/php.php" />
   <id>tag:agorian.com,2009:/help/web//9.488</id>
   
   <published>2009-03-27T02:37:05Z</published>
   <updated>2009-03-27T02:44:16Z</updated>
   
   <summary>※以下の記述は、２００６年頃にPHPを勉強しようと思って書いた。今はもっと分かり...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="PHP" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[※以下の記述は、２００６年頃にPHPを勉強しようと思って書いた。今はもっと分かりやすいサイトがあるかもしれない。<hr>
<p style="font-size: 10pt; font-family: sans-serif; margin-top: 0px; margin-left: 10px; margin-right: 10px; margin-bottom: 5px; "><a href="http://www.php.net/manual/ja/" style="font-size: 10pt; font-weight: bold; color: maroon; text-decoration: none; ">本家のPHPマニュアル</a><br>すべてを網羅しているが初心者には難しいかも。<br>
<br>
<a href="http://w1.nirai.ne.jp/freeze/" style="font-size: 10pt; font-weight: bold; color: maroon; text-decoration: none; ">ＰＨＰ入門講座</a><br>沖縄在住のＪＯＮさんのサイト。初心者がＰＨＰとはなにかを学ぶのに良い。多少プログラミングの概念がわかっていれば比較的容易にＰＨＰを理解できる。</p>
<p style="font-size: 10pt; font-family: sans-serif; margin-top: 0px; margin-left: 10px; margin-right: 10px; margin-bottom: 5px; "><br>
<a href="http://www.komonet.ne.jp/~php/index.shtml" style="font-size: 10pt; font-weight: bold; color: maroon; text-decoration: none; ">ＰＨＰの小部屋</a><br>いろいろ勉強できる「コモちゃん」のサイト。手軽に仕えるＰＨＰプログラムがあり参考になる。<br>
<br>
<a href="http://php.s3.to/" style="font-size: 10pt; font-weight: bold; color: maroon; text-decoration: none; ">レッツPHP</a><br>掲示板やカウンターのサンプルがわかりやすく解説してある。<br>
<br>
<a href="http://www.pat.hi-ho.ne.jp/dimension/" style="font-size: 10pt; font-weight: bold; color: maroon; text-decoration: none; ">Ｄｏ　Ｙｏｕ　ＰＨＰ？</a><br>ｐｈｐと関連ツール（Ｏｒａｃｌｅ，ＸＭＬ，ＯＯＰなど）を試した結果を公開している。<br>
<a class="link1" title="メールを送る" href="mailto:dimension@pat.hi-ho.ne.jp" style="font-size: 10pt; font-weight: bold; color: maroon; text-decoration: none; ">Hideyuki SHIMOOKA</a>さんのサイトです。<br>
<br>
<a href="http://masago.kir.jp/" style="font-size: 10pt; font-weight: bold; color: maroon; text-decoration: none; ">はなれPHP島</a></p>
<p></p>]]>
      
   </content>
</entry>
<entry>
   <title>RegExp 正規表現</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/javascript/regexp.php" />
   <id>tag:agorian.com,2009:/help/web//9.487</id>
   
   <published>2009-03-26T05:00:34Z</published>
   <updated>2009-03-26T05:49:55Z</updated>
   
   <summary>regexp = new RegExp(patern[, flag]) 正規表現...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="JavaScript" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[<h3 class="hdr"><em>regexp</em> = new RegExp(<em>patern</em>[, <em>flag</em>])</h3>
<p>正規表現オブジェクトを生成する。正規表現は文字列のパターンマッチング処理に使う。]]>
      <![CDATA[<table border="1" cellspacing="0" cellpadding="1" width="378"><tbody>
    <tr style="background-color: rgb(221, 221, 221); ">
    <th><em>flag</em></th><th>意味</th></tr>
    <tr><th>i</th><td>大文字・小文字を区別しない</td></tr>
    <tr><th>g</th><td>2番目、3番目... にマッチする部分も検索する</td></tr>
    <tr><th>m</th><td>複数行に対して検索する </td></tr>
 </tbody></table>

<h4>〔例１〕文字列DEFを含んでいるか調べる</h4>
<pre class="source">str = "ABCDEFG";
re = new RegExp("DEF", "i");
if (str.match(re)) {
    alert("DEFを含んでいます。");
}</pre>
<p>通常は、以下のように簡単に記述することが多い。
<pre class="source">str = "ABCDEF";
if (str.match(/DEF/i)) {
    alert("DEFを含んでいます。");
}</pre>

<h3 class="hdr">RegExp.$<em>記号</em></h3>
<table border="1" cellspacing="0" cellpadding="1" width="455">
  <tbody>
    <tr class="h" style="background-color: rgb(221, 221, 221); "><th>$記号</th><th>意味</th>
    </tr><tr>
      <th>$n</th><td>n番目の括弧に対応する文字列</td>
    </tr><tr>
      <th>$&amp;</th>
      <td>最後にマッチした文字列 (lastMatch)</td>
    </tr><tr>
      <th>$`</th>
      <td>マッチした部分の左側の文字列 (leftContext)</td>
    </tr><tr>
      <th>$&quot;</th>
      <td>マッチした部分の右側の文字列(rightContext)</td>
    </tr><tr>
      <th>$+</th>
      <td>最後の (...) に対応する文字列を返す (lastParen)</td>
    </tr><tr>
      <th>$_</th>
      <td>exec()<span class="Apple-converted-space">&nbsp;</span>でマッチングの対象とする文字列を代入 (input)</td>
    </tr><tr>
      <th>$*</th>
      <td>行頭（^）や行末（$）が各行の行頭、行末にマッチ (multiline)</td>
    </tr>
  </tbody>
</table>

<h3 class="hdr">正規表現の意味</h3>
<table border="1" cellspacing="0" cellpadding="1" width="85%">
  <tbody>
    <tr class="h" style="background-color: rgb(221, 221, 221); ">
      <th>正規表現</th>
      <th>意味</th>
    </tr>
    <tr>
      <th>A</th>
      <td>Aという文字</td>
    </tr>
    <tr>
      <th>ABC</th>
      <td>ABCという文字列</td>
    </tr>
    <tr>
      <th>[ABC]</th>
      <td>A、B、Cのいずれか1文字</td>
    </tr>
    <tr>
      <th>[A-C]</th>
      <td>A～Cまでのいずれか1文字</td>
    </tr>
    <tr>
      <th>[^ABC]</th>
      <td>A、B、Cのいずれでもない任意の1文字</td>
    </tr>
    <tr>
      <th>.</th>
      <td>任意の1文字</td>
    </tr>
    <tr>
      <th>A+</th>
      <td>1文字以上のA</td>
    </tr>
    <tr>
      <th>A*</th>
      <td>0文字以上のA</td>
    </tr>
    <tr>
      <th>A?</th>
      <td>0文字または1文字のA</td>
    </tr>
    <tr>
      <th>^A</th>
      <td>Aで始まる文字列</td>
    </tr>
    <tr>
      <th>A$</th>
      <td>Aで終わる文字列</td>
    </tr>
    <tr>
      <th>ABC|DEF|GHI</th>
      <td>ABCまたはDEFまたはGHI</td>
    </tr>
    <tr>
      <th>A{2}</th>
      <td>2個のA（AA）</td>
    </tr>
    <tr>
      <th>A{2,}</th>
      <td>2個以上のA（AA、AAA、AAAA、...）</td>
    </tr>
    <tr>
      <th>A{2,3}</th>
      <td>2個～3個のA（AA、AAA）</td>
    </tr>
    <tr>
      <th>[\b]</th>
      <td>バックスペース</td>
    </tr>
  </tbody>
</table>
<p style="text-indent: 1em; ">バックスラッシュ（\または￥）に続く文字は特別な意味を持つ。</p>
<table border="1" cellspacing="0" cellpadding="1" width="85%">
  <tbody>
    <tr class="h" style="background-color: rgb(221, 221, 221); ">
      <th>表現</th>
      <th>意味</th>
    </tr>
    <tr>
      <th>\b</th>
      <td>スペースなどの単語の区切り</td>
    </tr>
    <tr>
      <th>\B</th>
      <td>\b以外の文字</td>
    </tr>
    <tr>
      <th>\cA</th>
      <td>Ctrl-A</td>
    </tr>
    <tr>
      <th>\d</th>
      <td>任意の数値（[0-9]と同じ）</td>
    </tr>
    <tr>
      <th>\D</th>
      <td>数値以外の文字（[^0-9]と同じ）</td>
    </tr>
    <tr>
      <th>\f</th>
      <td>フォームフィード文字</td>
    </tr>
    <tr>
      <th>\n</th>
      <td>改行文字</td>
    </tr>
    <tr>
      <th>\r</th>
      <td>復帰文字</td>
    </tr>
    <tr>
      <th>\s</th>
      <td>1文字の区切り文字（[ \f\n\r\t\v]）</td>
    </tr>
    <tr>
      <th>\S</th>
      <td>\s以外の1文字</td>
    </tr>
    <tr>
      <th>\t</th>
      <td>タブ文字</td>
    </tr>
    <tr>
      <th>\v</th>
      <td>垂直タブ文字</td>
    </tr>
    <tr>
      <th>\w</th>
      <td>英数文字（[A-Za-z0-9_]と同じ）</td>
    </tr>
    <tr>
      <th>\W</th>
      <td>\w以外の文字</td>
    </tr>
    <tr>
      <th>\2</th>
      <td>2番目の (...) にマッチした文字列</td>
    </tr>
    <tr>
      <th>\o033</th>
      <td>8進数で033の文字</td>
    </tr>
    <tr>
      <th>\x1b</th>
      <td>16進数で1bの文字</td>
    </tr>
    <tr>
      <th>\その他</th>
      <td>その他の文字自身</td>
    </tr>
  </tbody>
</table>
]]>
   </content>
</entry>
<entry>
   <title>ファイルの書込み</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/phpscript/file-put-contents.php" />
   <id>tag:agorian.com,2008:/help/web//9.426</id>
   
   <published>2008-09-24T19:57:11Z</published>
   <updated>2008-11-17T19:11:10Z</updated>
   
   <summary>file_put_contents　文字列をファイルに書き込む int file...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="PHP" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[<h2 class=hdr>file_put_contents　文字列をファイルに書き込む</h2>
<div class=box>int file_put_contents  ( string $filename  , mixed $data  [, int $flags  [, resource $context  ]] )</div>
関数file_put_contentsは、PHP5の機能で、PHP４にはない。この関数を使うと、fopen()、fwrite()、 fclose() を続けてコールしてデータをファイルに書き込むのとおなじことができる。PHP4しかサポートしていないサーバがまだ多いので、fopen()、fwrite()、 fclose() で書いておいたほうがいい。

<h2 class=hdr>fopen　ファイルまたは URL をオープンする</h2>
<div class=box>resource fopen  ( string $filename  , string $mode  [, bool $use_include_path  [, resource $context  ]] )</div>
〔例〕<pre class=source>&lt;?php
$handle = fopen("/home/rasmus/file.txt", "r");
$handle = fopen("/home/rasmus/file.gif", "wb");
$handle = fopen("<A href="http://www.example.com/">http://www.example.com/</A>", "r");
$handle = fopen("<A href="ftp://user:password@example.com/somefile.txt">ftp://user:password@example.com/somefile.txt</A>", "w");
?&gt;</pre>
プロトコルのハンドラ（ラッパーともいう）のサポート、セーフモード、open_basedir有効 、php.iniでのallow_url_fopenなどの状態によっては、URLの書込みオープンができない。w 書込みのみ。　w+ 読み込みと書込み。ファイルポインターを先頭に置く。追加書き込みをするときは、ファイルポインターを終端に置く a または a+ を指定してオープンする。<br>


<h2 class=hdr>fwrite ― バイナリセーフなファイル書き込み処理</h2>
string の内容を handle が指しているファイル・ストリームに書き込みます。
<div class=box>int fwrite  ( resource $handle  , string $string  [, int $length  ] )</div>
handle - fopen() を使用して作成したファイルシステムポインタリソース<br>
string - 書き込む文字列<br>

<h3 class="bold s14">〔例１〕文末に文字列を追加する</h3><pre class=source><SPAN style="COLOR: rgb(0,0,0)"><SPAN style="COLOR: rgb(0,0,187)">&lt;?php
$filename&nbsp;</SPAN><SPAN style="COLOR: rgb(0,119,0)">=&nbsp;</SPAN><SPAN style="COLOR: rgb(221,0,0)">'test.txt'</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$somecontent&nbsp;</SPAN><SPAN style="COLOR: rgb(0,119,0)">=&nbsp;</SPAN><SPAN style="COLOR: rgb(221,0,0)">"Add&nbsp;this&nbsp;to&nbsp;the&nbsp;file\n"</SPAN><SPAN style="COLOR: rgb(0,119,0)">;

</SPAN><SPAN style="COLOR: rgb(255,128,0)">//&nbsp;ファイルが存在しかつ書き込み可能かどうか確認します
</SPAN><SPAN style="COLOR: rgb(0,119,0)">if&nbsp;(</SPAN><SPAN style="COLOR: rgb(0,0,187)">is_writable</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$filename</SPAN><SPAN style="COLOR: rgb(0,119,0)">))&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: rgb(255,128,0)">//&nbsp;この例では$filenameを追加モードでオープンします。
&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;ファイルポインタはファイルの終端になりますので
&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;そこがfwrite()で$somecontentが追加される位置になります。
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: rgb(0,119,0)">if&nbsp;(!</SPAN><SPAN style="COLOR: rgb(0,0,187)">$handle&nbsp;</SPAN><SPAN style="COLOR: rgb(0,119,0)">=&nbsp;</SPAN><SPAN style="COLOR: rgb(0,0,187)">fopen</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$filename</SPAN><SPAN style="COLOR: rgb(0,119,0)">,&nbsp;</SPAN><SPAN style="COLOR: rgb(221,0,0)">'a'</SPAN><SPAN style="COLOR: rgb(0,119,0)">))&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</SPAN><SPAN style="COLOR: rgb(221,0,0)">"Cannot&nbsp;open&nbsp;file&nbsp;($filename)"</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: rgb(255,128,0)">//&nbsp;オープンしたファイルに$somecontentを書き込みます
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: rgb(0,119,0)">if&nbsp;(</SPAN><SPAN style="COLOR: rgb(0,0,187)">fwrite</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$handle</SPAN><SPAN style="COLOR: rgb(0,119,0)">,&nbsp;</SPAN><SPAN style="COLOR: rgb(0,0,187)">$somecontent</SPAN><SPAN style="COLOR: rgb(0,119,0)">)&nbsp;===&nbsp;</SPAN><SPAN style="COLOR: rgb(0,0,187)">FALSE</SPAN><SPAN style="COLOR: rgb(0,119,0)">)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</SPAN><SPAN style="COLOR: rgb(221,0,0)">"Cannot&nbsp;write&nbsp;to&nbsp;file&nbsp;($filename)"</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</SPAN><SPAN style="COLOR: rgb(221,0,0)">"Success,&nbsp;wrote&nbsp;($somecontent)&nbsp;to&nbsp;file&nbsp;($filename)"</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: rgb(0,0,187)">fclose</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$handle</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
}&nbsp;else&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</SPAN><SPAN style="COLOR: rgb(221,0,0)">"The&nbsp;file&nbsp;$filename&nbsp;is&nbsp;not&nbsp;writable"</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
}
</SPAN><SPAN style="COLOR: rgb(0,0,187)">?&gt;</SPAN> </SPAN>
</pre>

<div class="bold s14">〔例２〕カウンタ・ファイル書込み   <?php
$file = "counter.txt";
if ( !file_exists($file)){
        touch ($file);
        $handle = fopen ($file, 'r+');
        $str = "<? \$count=0 ?>";
}
else{
        include "counter.txt";
        $count++;
        $str = "<? \$count=".$count." ?>";
        $handle = fopen ($file, 'r+');
}
fwrite ($handle, $str);
print ($count);
fclose ($handle);
?></div>

<pre class=source>&lt;?
$file = "counter.txt";
if ( !file_exists($file)){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; touch ($file);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $handle = fopen ($file, 'r+');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $str = "&lt;? \$count=0 ?&gt;";
}
else{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; include "counter.txt";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $count++;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $str = "&lt;? \$count=".$count." ?&gt;";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $handle = fopen ($file, 'r+');
}
fwrite ($handle, $str);
fclose ($handle);
?&gt;</pre>


<h2 class=hdr>fclose ― オープンされたファイルポインタをクローズする</h2>
<div class=box>bool fclose  ( resource $handle  )</div>
〔例〕<Pre class=source>&lt;?php
$handle = fopen('somefile.txt', 'r');
fclose($handle);
?&gt;</Pre>

]]>
      
   </content>
</entry>
<entry>
   <title>File</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/phpscript/file.php" />
   <id>tag:agorian.com,2008:/help/web//9.425</id>
   
   <published>2008-09-24T17:30:57Z</published>
   <updated>2008-09-24T22:09:11Z</updated>
   
   <summary>ファイル全体を読み込んで配列に格納する array file  ( string...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="PHP" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[<div class=hdr>ファイル全体を読み込んで配列に格納する</div>
<div class=box>array file  ( string $filename  [, int $flags  [, resource $context  ]] )</div>

〔例1〕
<Pre class=source>&lt;?php
// ファイルの内容を配列に取り込みます。
// この例ではHTTPを通してURL上のHTMLソースを取得します。
$lines = file('http://agorian.com/help/web/php/input.html');
// 配列をループしてHTMLをHTMLソースとして表示します。
//行番号をつけるときは、echo "Line #&lt;b&gt;{$line_num}&lt;/b&gt; : "
foreach ($lines as $line_num =&gt; $line) {
&nbsp;&nbsp;&nbsp; echo&nbsp; htmlspecialchars($line) . "&lt;br /&gt;\n";
}
?&gt;</Pre>

<div class=result>
<?php
// ファイルの内容を配列に取り込みます。
// この例ではHTTPを通してURL上のHTMLソースを取得します。
$lines = file('http://agorian.com/help/web/php/input.html');

// 配列をループしてHTMLをHTMLソースとして表示します。
//行番号をつけるときは、echo "Line #<b>{$line_num}</b> : "
foreach ($lines as $line_num => $line) {
    echo  htmlspecialchars($line) . "<br />\n";
}
?>
</div>
〔例２〕
<pre class=source>&lt;?php
// 他の例として、Webページを文字列に取り込みます。file_get_contents()も参照してください。
$html = implode('', file('http://agorian.com/help/web/php/input.html'));
echo $html;
?&gt;
</pre>

<div class=result>
<?php
// 他の例として、Webページを文字列に取り込みます。file_get_contents()も参照してください。
$html = implode('', file('http://agorian.com/help/web/php/input.html'));
echo $html;
?></div>

<h2 class=hdr>説明</h2>
例1を使うと、指定したURLのファイルを読み込んでそのまま表示できる。例2では、ブラウザがHTMLタグを解釈して表示してくれる。この二つを使って、HTMLソースとブラウザ表示の両方を例示することができる。例1を改変して、Textareaに表示、それを編集してファイルに書き出セル用にすれば、簡単なウェブでのテキストエディタを作れる。オープンソースのWebエディターがあるので、それを解読して改変するといい。FCKEditorを改変して、指定したURLにあるファイルをWYSIWYG編集して更新できるようにしてみよう。次はファイルの書込みの勉強だ。
]]>
      
   </content>
</entry>
<entry>
   <title>PHP memo</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/phpscript/php-memo.php" />
   <id>tag:agorian.com,2008:/help/web//9.424</id>
   
   <published>2008-09-24T15:15:46Z</published>
   <updated>2009-05-28T16:58:58Z</updated>
   
   <summary>2006年秋からPHPを使うことが多くなった。オープンソースソフトのほとんどがP...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="PHP" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[2006年秋からPHPを使うことが多くなった。オープンソースソフトのほとんどがPHPで書かれているから必要に迫られたということ。しかし、PHPスクリプト（言語、コード）の文法や意味はほとんど知らない。知らなくても、どんなPHPコードを書いて実行するとどんな結果になるかは分かる。だから見よう見まねでPHPを改変することを試行錯誤でやってきた。PHPで書かれたSNSソフトもおなじように改変してサーバに設置し運営している。

前々からPHPを勉強しようと思っていたが遅々として進まない。勉強して分かったと思っていてもすぐ忘れるのでメモをとることにした。


PHPコードは、HTML文書の中に、&lt;?php と ?&gt; で囲んで書くだけだ。ただし、そのHTMLファイルの拡張子は .html ではなく<strong> .php </strong>にする。ブラウザが、この拡張子のときは、そのファイルの中に php コードがあると判断して、PHPインタープリータを動かしてくれる。PHPインタープリータは、PHPコードを解釈して実行してくれる。&lt;?php は &lt;? でもよい。

たとえば、<strong>&lt;?php echo "こんにちは"; ?&gt;</strong> というPHPコードを解釈すると、そのコードの位置に、「こんにちは」という文字列を埋め込んでくれる。言い換えると、&lt;～&gt; の部分が「こんにちは」で置き換えられたHTMLファイルが作られて、ブラウザで表示されるということだ。それなら、最初から「こんにちは」と書いておけばよいではないか・・・。この場合はそのとおりだ。

たとえば、ブラウザでｐｈｐファイルを開いたときの時刻を表示するphpコードを書いてみる。
<div class=box>&lt;?php$time = date("西暦Y年n月j日　Ah:i");print($time);?&gt;</div>このｐｈｐは以下のように表示される。
<div class=box><?php $time = date("西暦Y年n月j日　Ah:i");print($time);?></div>
文字修飾をしてみよう。赤色の太字で時刻を表示する。
<div class=box>&lt;font color=red weight=bold&gt;&lt;?php$time = date("西暦Y年n月j日　Ah:i");print($time);?&gt;&lt;/font&gt;</div>→<span class=box><font color=red weight=bold><?php $time = date("西暦Y年n月j日　Ah:i");echo($time);?></font></span>

dateで得られた値（この場合は文字列）を$timeに代入し、$timeをprintで印刷（表示）するというPHPコードだ。printはechoと同じである。

$time のように先頭が$ではじまる文字列を、PHP変数という。date はPHPで用意されている関数で、それに続く（～）は date の引数（パラメータ）だ。Y n j Ah i はdate関数でその意味が決められている。Y は4桁の西暦年、n は月・・・というように決められている。2008年9月の場合、Yn は 20089 、ym は0809 に置き換えられる。"～" は文字列データを示す。

PHPコードでは、半角空白や改行は無視される。ただし、全角の空白は"～"のなかでは空白の文字だが、それ以外に記述するとエラーになるので注意が必要だ。なお、ブログなどでWYSIWYGエディタで作成すると改行は、&lt;br&gt;に変換されることがあり、そのときはPHPエラーになる。

PHPコードの構造を分かりやすくするために以下のように記述をするが、転写すると ; のつぎに &lt;br&gt; が入っていることがあるので注意する。また、文字コード系は、Unicode(UTF-8)に統一するのが望ましい。JISやEUCを使うと文字化けが発生したり、PHPエーになったりすることが多い。
<div class=box>&lt;?php
$time = date("西暦Y年n月j日　Ah:i");
print($time);
?&gt;
</div>

〔注〕時刻はPHPファイルが保存されているサーバの時刻になる。本サイトは米国にあるので、日本時刻で表示するときは、<a href="http://agorian.com/help/web/phpscript/date.php">こちら</a>のようにする。
〔参考リンク〕<ul><li><a href="http://www.php.net/manual/ja/">PHPマニュアル</a><li><a href="http://www.php.net/">PHP言語開発元</a>（英語）<li><a href="http://www.php.gr.jp/">日本PHPユーザ会</a></ul>]]>
      
   </content>
</entry>
<entry>
   <title>このサイトについて</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/about/about.php" />
   <id>tag:agorian.com,2008:/help/web//9.389</id>
   
   <published>2008-06-15T19:06:09Z</published>
   <updated>2009-03-27T01:47:51Z</updated>
   
   <summary>　Webサービスやサーバ運営、ホームページ、ＳＮＳ、ブログ、スクリプトなどの制作...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="About" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[<p>　Webサービスやサーバ運営、ホームページ、ＳＮＳ、ブログ、スクリプトなどの制作で学んだことを整理している。以下のリンク先は手作りのドキュメントだったものをMTに移行中だ。</p>
    <UL>
      <LI><A href="http://agorian.com/help/web/browser/index.html">Webブラウザ</A>
      <LI><a href="http://agorian.com/help/web/homepage/">ホームページ入門</a>
      <LI><A href="http://agorian.com/help/web/html/index.html">HTML入門</A>
      <LI><A href="http://agorian.com/help/web/style/index.html">スタイルシート</A>
      <LI><a href="http://agorian.com/help/web/javascript/index.html">Javascript</a>
      <LI><a href="http://agorian.com/help/web/phpscript/index.html">PHPスクリプト</a>
      <LI><a href="http://agorian.com/help/web/tools/index.html">Web便利ツール</a>
      <LI><a href="http://agorian.com/help/player/index.html">Web Player</a>
    </UL>]]>
      <![CDATA[<p>※手作りの<a href="http://elmblog.com/study/index.html">学習手帳</a>およびこれのMTへの移行を試みた<a href="http://elmblog.com/web/study/">過去のコンテンツ</a>、さらに「<a href="http://agorian.com/">デジタル移民の冒険</a>」で書き溜めた記事を整理して、Helpサイトに統合しようとしている。もうひとつ手作りの<a href="http://agorian.com/help/">Helpメモ</a>があった。どれも未完成のままだ。</p>
<p>※目的別に分けたほうがいいだろう。
<UL>
<li>Javascript, PHP・・・MT3.5を使う。MT4やWPではスクリプトに制限がある。
<li>Windows/Webアプリケーションやサービスの説明・・・MT4で大丈夫だろう。
<li>CMS・ブログ共用・・・Drupalが適切だろう。ブログは公開前の下書きに使う。
</UL>
<p>MTOS4.25では、PHPインクルードがオプションで使えそうだ。確認できたら、MT3.5をMT4.25に移行する。写真や動画のヘルプをどれに統一するか？

]]>
   </content>
</entry>
<entry>
   <title>Webホスティング</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/memo/webhosting.php" />
   <id>tag:agorian.com,2008:/help/web//9.347</id>
   
   <published>2008-06-10T17:15:17Z</published>
   <updated>2008-06-15T16:17:57Z</updated>
   
   <summary>Webの学習や試作の場合は、無料のウェブホスティングサービスの利用をお勧めする。...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="Memo" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[Webの学習や試作の場合は、無料のウェブホスティングサービスの利用をお勧めする。自分のWebに広告が表示されるだけで、Web制作に必要な機能はほとんど使用できる。

自分のWeb（ホームページ）を作りならいろんな機能やツールを学ぶのがよい。ある程度分かって、本格的に自分のWebを作って公開したり、友人・知人との情報共有に活用するときに、サポートが充実した有料のWebホスティングサービス契約をするといい。

英語に抵抗がない人にお勧めするのは、<a href="http://www.bravenet.com/webhosting/">Bravenet</a>です。Web制作に必要なほとんどの機能や便利なスクリプトなどがたくさんあります。私もずいぶんBravenetにお世話になっています。

無料ホスティングで使えるスペースは５０MBです。写真やビデオを多用しない限り、個人用Web（ホームページ）としては十分な容量です。ブログやSNS、CMS、Wikiなどのソフトウェアも設置して運用できます。

∇<a href="http://agorian.com/web/page/000331.html">ドメイン取得比較</a>
∇<a href="http://agorian.com/web/page/000330.html">レンタルサーバ比較</a>]]>
      
   </content>
</entry>
<entry>
   <title>1.5 ブラウザで表示する</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/homepage/105.php" />
   <id>tag:agorian.com,2008:/help/web//9.346</id>
   
   <published>2008-06-05T22:30:38Z</published>
   <updated>2008-06-05T23:35:12Z</updated>
   
   <summary>作成した test.html をブラウザで表示します。 ブラウザ（IE とします...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="Homepage" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[<p>作成した test.html をブラウザで表示します。
<ul>
<li>ブラウザ（IE とします）を起動します。[スタート]-[すべてのプログラム(P)]-[Internet Explorer] などから起動することができます。
<li>ブラウザ（IE）の [ファイル(F)]→[開く(O)...]→[参照(R)...] で、[マイ ドキュメント]→[MyHome] の中の test.html を選択して、 [開く(O)] ボタンを押します。
</ul> 
<img src="http://agorian.com/help/web/homepage/001.png">

<p>左がメモ帳で作成したテキストです。これを、test.html の名前で保存したものをブラウザで開いたホームページです。スクリーンショットの例はFireFoxですが、IEでもおなじように表示されます。
<p>「初めてのホームページです。」と表示されています。メモ帳で、<body>と</body>の間に書いたテキストです。<title>と</title>の間に書いたテキストがブラウザのタイトルに表示されていることを確認してください。
<p>これでとりあえずホームページが完成です。あとは、メモ帳で、<body>と</body>の間に、ホームページの内容（コンテンツ）を書いていきます。]]>
      
   </content>
</entry>
<entry>
   <title>1.4 メモ帳でＨＴＭＬを書く</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/homepage/104.php" />
   <id>tag:agorian.com,2008:/help/web//9.345</id>
   
   <published>2008-06-05T21:22:00Z</published>
   <updated>2009-07-13T10:00:39Z</updated>
   
   <summary>メモ帳などのテキストエディタで HTML 文書を作成します。メモ帳以外のテキスト...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="Homepage" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[<p>メモ帳などのテキストエディタで HTML 文書を作成します。メモ帳以外のテキストエディタでも構いません。Word などのワープロを用いる場合は、保存時にテキストファイルとして保存する必要があります。
<ul>
<li>[スタート]→[すべてのプログラム(P)]→[アクセサリ]→[メモ帳] を起動します。
<li>メモ帳につぎのテキストを入力します。
</ul>
<pre class="code">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;ホームページの作成&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
初めてのホームページです。
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>これを、 [MyHome] フォルダの中に test.html という名前で保存します。
<ul>
<li>メモ帳の [ファイル(F)]→[名前を付けて保存(A)] を実行します。
<li>ファイルの種類(T):「 テキスト文書(*.txt)」をクリックして、「すべてのファイル(*.*)」を選択します。
<li> [マイ ドキュメント] の中から先ほど作成した MyHome フォルダをダブルクリックして開きます。
<li> [ファイル名(N)] に test.html と入力して、[保存(S)] ボタンを押します。 
</ul>
※ファイルの種類が「テキスト文書(*.txt)になっていると、test.html.txt という名前で保存されますので注意してください。

<h3 class="hdr">ファイル名に関する注意</h3>

ホームページで作成する HTML文書や画像ファイルのファイル名を付けるときは、以下の点に注意してください。
<ul>
<li>基本的に、<strong>半角英数字のみ</strong>を用いる。漢字やかな入力で変換した英数字を使わない。
<li>使用可能な記号はドット（.）、ハイフン（-）、アンダーバー（_）です。
<li>スペース文字を含んだファイル名は使用しない。
<li>大文字・小文字を使い分ける。 
</ul><pre class="code">○ test.html
○ test-page.html
× test&page.html
× Test Page.html
× テスト.html
</pre>
<p>※Windows で作成しているときは test.html も TEST.html も同じファイルとみなされますが、サーバーにアップロードすると別のファイルとして扱われることがあります。大文字と小文字の使い分け に注意が必要です。間違いを避けるためには、すべて小文字の英数字を使ったほうが良い。

<h3 class="hdr">拡張子に関する注意</h3>

<p>HTML 文書の拡張子は通常 .html ですが、Windows 3.1 など古いシステムで拡張子に 3文字しか使用できなかったことから、未だに .htm とすることがあります。 .htm でも .html でもどちらでも構いませんが、間違いを避けるために、どちらかに統一して使ったほうがいい。
]]>
      
   </content>
</entry>
<entry>
   <title>1.3 フォルダを作成する</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/homepage/103.php" />
   <id>tag:agorian.com,2008:/help/web//9.344</id>
   
   <published>2008-06-05T20:55:13Z</published>
   <updated>2009-05-28T16:59:27Z</updated>
   
   <summary>これから作成する各種ファイルを格納するためのフォルダを作成します。例では、MyH...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="Homepage" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[<p>これから作成する各種ファイルを格納するためのフォルダを作成します。例では、MyHomeというフォルダを使います。つぎの手順で、[マイ ドキュメント] の下に MyHome という名前のフォルダを作成します。
<ol>
<li>[スタート]→[すべてのプログラム(P)]→[アクセサリ]→[エクスプローラ] でエクスプローラ(※)を起動します。
<li>左側のツリーで [マイ ドキュメント] を選択した状態で、メニューから [ファイル(F)]→[新規作成(W)]→[フォルダ(F)] を実行します。
<li>[新しいフォルダ] が作成されます。[ファイル(F)]→[名前の変更(M)] で、フォルダの名前を「新しいフォルダ」から「MyHome」に変更します。 
</ol>
<p>※ エクスプローラとインターネットエクスプローラ（IE)は別のプログラムです。IEはホームページを表示するブラウザ(iexplore.exe)です。エクスプローラ(explore.exe)は、ディスク上のファイルやフォルダを表示します。
<p>※ デスクトップに フォルダを作成するときは、画面上でマウスを右クリックして、[新規作成]→[フォルダ]を実行します。フォルダを右クリックして[名前を変更]することができます。

<h3 class="hdr">拡張子を表示する</h3>
<p>
ホームページの作成では、拡張子（ファイル名末尾の .txt や .html などの文字）は非常に重要です。下記の手順で拡張子を表示するように変更してください。
<ol>
<li>エクスプローラの [ツール(T)]→[フォルダオプション(O)...] を実行します。
<li>[表示] タブの中の [登録されている拡張子は表示しない] をオフ（チェックをつけない）にして [OK] ボタンを押してください。 

]]>
      
   </content>
</entry>
<entry>
   <title>1.2 ブラウザとメモ帳を使う</title>
   <link rel="alternate" type="text/html" href="http://agorian.com/help/web/homepage/102.php" />
   <id>tag:agorian.com,2008:/help/web//9.343</id>
   
   <published>2008-06-05T20:10:28Z</published>
   <updated>2008-06-15T20:22:29Z</updated>
   
   <summary>ホームページを作成するのに必要なのは、つぎの二つのツールです。 ブラウザ ブラウ...</summary>
   <author>
      <name>達磨居士</name>
      <uri>http://agorian.com/</uri>
   </author>
         <category term="Homepage" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="ja" xml:base="http://agorian.com/help/web/">
      <![CDATA[<p>ホームページを作成するのに必要なのは、つぎの二つのツールです。
<ol>
<li>ブラウザ<br>
ブラウザとは、このページを見るために使っているツール（ソフトウェア）です。Windowsパソコンであれば、セットアップしたときに使えるようになっているマイクロソフト社の Internet Explorer を利用する人が多い。以下の説明では、Internet Explorer のことを IE と書きます。ほかのブラウザについては、<a href="http://agorian.com/help/web/browser/">こちら</a>を参考にしてください。<br /><br />

<li>テキストエディタ<br />
最初は、Windows の場合はメモ帳 ( notepad.exe)、Macintosh の場合は SimpleText があれば十分です。メモ帳は、[スタート]→[すべてのプログラム(P)]→[アクセサリ]→[メモ帳] にあります。
</ol>

<p>以下の説明では、「Windows XP」で「Internet Explorer 6.0」と「メモ帳」を用いた例を示します。ほかのブラウザ（Netscape、Firefox、Operaなど）の場合、メニューの名前が異なる場合がありますが、適切に読み替えてください。
]]>
      
   </content>
</entry>

</feed>

