c:nmp:2016:week10
Table of Contents
Web development
- Apache Apache HTTP Server, 나무위키 or Apache HTTP Server, Wikipedia
- PHP PHP, 나무위키
- mysql MySQL, 나무위키
- Installation
- D:/Wamp64
- 브라우저에서 localhost 로 접속 (http://localhost 혹은 http://127.0.0.1)
- vhost option 켜기
# Include conf/extra/httpd-vhosts.conf
- –>
Include conf/extra/httpd-vhosts.conf
- httpd-vhosts.conf 수정
<VirtualHost *:80> ServerName localhost DocumentRoot D:/Wamp64/www <Directory "D:/Wamp64/www/"> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> </VirtualHost> <VirtualHost *:80> ServerName nmp-project DocumentRoot d:/www/nmp-project <Directory "d:/www/nmp-project/"> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> </VirtualHost>
HTML
- put index.php file in nmp-project directory
- index.php
<?php echo "hello world"; ?>
- index.php
<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1>This is a Heading</h1> <p>This is a paragraph.</p> <?php echo "<p>This is php part.</p>"; ?> </body> </html>
- index.php
<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1>This is a heading</h1> <h2>This is a heading</h2> <h3>This is a heading</h3> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <a href="http://www.w3schools.com">This is a link</a> <img src="http://www.w3schools.com/html/w3schools.jpg" alt="W3Schools.com" width="104" height="142"> </body> </html>
- 특히 스타일 (style)
- index.php
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="styles.css"> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> </html>
- styles.css
body { background-color: lightgrey; } h1 { color: blue; } p { color:green; }
PHP
Open API
- naver_movie.php
<!DOCTYPE html> <html><head> <meta charset="UTF-8"> </head> <body> <?php $txt=''; $myfile = fopen("naver.out.txt", "w"); $lines = file('movie.dat'); $key = "9912dee981255d08ef6fb39c5f104069"; $year = "&yearfrom=2003&yearto=2004"; for ($i=0;$i<sizeof($lines);$i++) { $query=trim($lines[$i]); $url = "http://openapi.naver.com/search?key=".$key."&query=".$query."&target=movie"; echo "<hr />"; echo "Requested URL: " . $url ."\n\n<br />\n\n"; $xml = simplexml_load_file($url); // output raw starts /* print "<pre>"; print_r($xml->channel); print "</pre>"; echo "<br /><br />"; */ // output raw ends foreach ($xml->channel->item as $movie) { // since exact query is not possible $title=strip_tags($movie->title); $subtitle=strip_tags($movie->subtitle); $year = $movie->pubDate; $dire = $movie->director; $dire = "\"".str_replace("|", "\" \"", $dire)."\""; $dire = str_replace("\"\"", "", $dire); $actor = trim($movie->actor); $actor = "\"".str_replace("|", "\" \"", $actor)."\""; $actor = str_replace("\"\"", "", $actor); $nRating = $movie->userRating; $txt = $title."\t".$subtitle."\t".$year."\t".$dire."\t".$actor."\t".$nRating."\n"; $webtxt = "<br />*****<br />". $txt . "<br />*****<br />"; echo $webtxt; fwrite($myfile, $txt); $txt=''; // } else { } } } fclose($myfile); ?> </body></html>
- movie.dat
Interstellar Citizen Kane The Sixth Sense Predestination
c/nmp/2016/week10.txt · Last modified: 2016/07/01 15:00 by hkimscil