2012年5月31日木曜日

WEBサーバの利用

1.public_htmlへ移動
# cd public_html
2.index.htmlを作成
# vi index.html

<html>
<head>
<link rel="stylesheet" href="base.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>テスト</title>
<body>
テスト
</body>
</html>
3.base.cssを作成
body {
 font: normal normal 14px Arial, Tahoma, Helvetica, FreeSans, sans-serif;
 color: #000000;
 background: #aabbaa none no-repeat scroll center center;
 font-family:'ヒラギノ角ゴ Pro W3','Hiragino Kaku Gothic Pro','メイリオ',Meiryo,'MS Pゴシック',sans-serif;
}

html body .region-inner {
 min-width: 0;
 max-width: 100%;
 width: auto;
}

.content-outer {
 font-size: 90%;
}

a:link {
 text-decoration:none;
 color: #445566;
}
a:visited {
 text-decoration:none;
 color: #000000;
}
a:hover {
 text-decoration:underline;
 color: #1455ff;
}
4.phpinfo.phpを作成
# vi phpinfo.php

<?php
  phpinfo();
?>

#chmod 755 phpinfo.php
4.Hello, World!
# vi hello.php

<?php
echo "Hello World!";
?>

# chmod 755 hello.php
5.文字列表示・結合
# vi test.php

<?php
$str1 = "Hello";
$str2 = "World";

print<<<EOF
<html>
<head>
<link rel="stylesheet" href="base.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>テスト2</title>
<body>
テスト2
<br>
EOF;

echo $str1.",".$str2;

print<<<EOF
</body>
</html>
EOF;
?>

# chmod 755 test.php
6.外部APIの利用(twitter)
# vi twitter.php

<?php
 $word = "横浜";
 $url = "http://search.twitter.com/search.rss?q=".$word;

 $rss = simplexml_load_file($url);

 $title = $rss->channel->item->title;
 $link = $rss->channel->item->link;
 $description = $rss->channel->item->description;
 $pubDate = $rss->channel->item->pubDate;
 $author = $rss->channel->item->author;

print<<<EOF
 <html>
 <head>
 <link rel="stylesheet" href="base.css" />
 <title>twitter sample</title>
 </head>
 <body>
EOF;

 print "title : ".$title."<br />";
 print "link : ".$link."<br />";
 print "description : ".$description."<br />";
 print "pubDate : ".$pubDate."<br />";
 print "author : ".$author."<br />";
 print "image_link : ".$iage_link."<br />";

print<<<EOF
 </body>
 </html>
EOF;
?>

#chmod 755 twitter.php

0 件のコメント: