How to setup a web development environment Welcome to our first video tutorial. Where I’m going to show you in detail how to setup a local web development environment. This tutorial is for novices and beginner in web development. Most of us are using Windows systems, this is because I selected WAMP at the most appropriate tool for us. We will install WAMP at our computer, and I will show you how you can use your database (phpMyAdmin), and, as some extra – I will show you a process of making own php-based RSS feed (on PHP).
如何设置Web开发环境欢迎来到我们的第一个视频教程。 在这里,我将详细向您展示如何设置本地Web开发环境。 本教程适用于Web开发的新手和初学者。 我们大多数人都使用Windows系统,这是因为我选择了WAMP作为最适合我们的工具。 我们将在计算机上安装WAMP,我将向您展示如何使用数据库(phpMyAdmin),以及一些额外的功能–我将向您展示制作自己的基于PHP的RSS feed(在PHP上)的过程。
After you have finished this video, you can copy and test the code we have just made:
播放完此视频后,您可以复制和测试我们刚才制作的代码:
<?
// step 1 - we should connect to database and take all our records:
$vLink = mysql_connect('localhost', 'root', ''); // this is default username and password for WAMP
mysql_select_db('test_db', $vLink);
mysql_query('SET names UTF8'); // let's set UTF8 mode (in order to support unicode)
$sSQL = 'SELECT * FROM `stories` ORDER BY `id` DESC'; // this is our SQL query to take our records
$vRes = mysql_query($sSQL); // execution of query
$aStories = array(); // an empty array to collect stories (records)
if ($vRes) {
while($aRow = mysql_fetch_array($vRes, MYSQL_ASSOC)) { // lets walk through all the records
$aStories[] = $aRow;
}
mysql_free_result($vRes);
}
// check
// print_r($aStories); // well done
// step 2 - display data array as rss feed
$sFeeds = '';
foreach ($aStories as $aStory) { // let's walk through all the records again and prepare Items for RSS
$sFeeds .= <<<EOF
<item>
<guid><![CDATA[{$aStory['id']}]]></guid>
<link><![CDATA[story.php?id={$aStory['id']}]]></link>
<title><![CDATA[{$aStory['title']}]]></title>
<description><![CDATA[{$aStory['description']}]]></description>
<pubDate>{$aStory['when']}</pubDate>
</item>
EOF;
}
// now - we should prepare necessary header and output our RSS feed:
header('Content-Type: text/xml; charset=utf-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>Our own RSS feed</title>
<link>http://localhost/feed.php</link>
<description>Our own RSS feed</description>
<lastBuildDate>2012-07-16 00:00:00</lastBuildDate>
{$sFeeds}
</channel>
</rss>
EOF;
<?
// step 1 - we should connect to database and take all our records:
$vLink = mysql_connect('localhost', 'root', ''); // this is default username and password for WAMP
mysql_select_db('test_db', $vLink);
mysql_query('SET names UTF8'); // let's set UTF8 mode (in order to support unicode)
$sSQL = 'SELECT * FROM `stories` ORDER BY `id` DESC'; // this is our SQL query to take our records
$vRes = mysql_query($sSQL); // execution of query
$aStories = array(); // an empty array to collect stories (records)
if ($vRes) {
while($aRow = mysql_fetch_array($vRes, MYSQL_ASSOC)) { // lets walk through all the records
$aStories[] = $aRow;
}
mysql_free_result($vRes);
}
// check
// print_r($aStories); // well done
// step 2 - display data array as rss feed
$sFeeds = '';
foreach ($aStories as $aStory) { // let's walk through all the records again and prepare Items for RSS
$sFeeds .= <<<EOF
<item>
<guid><![CDATA[{$aStory['id']}]]></guid>
<link><![CDATA[story.php?id={$aStory['id']}]]></link>
<title><![CDATA[{$aStory['title']}]]></title>
<description><![CDATA[{$aStory['description']}]]></description>
<pubDate>{$aStory['when']}</pubDate>
</item>
EOF;
}
// now - we should prepare necessary header and output our RSS feed:
header('Content-Type: text/xml; charset=utf-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>Our own RSS feed</title>
<link>http://localhost/feed.php</link>
<description>Our own RSS feed</description>
<lastBuildDate>2012-07-16 00:00:00</lastBuildDate>
{$sFeeds}
</channel>
</rss>
EOF;
下载包
翻译自: https://www.script-tutorials.com/how-to-setup-a-web-development-environment/