初学PHP的18个基础例程

二:如何输出文本或者把文本建立连接用PHP

  在PHP中如何显示文本呢?使用下面的命令:

<?php echo "Hello in php";?>

  如何创建一个连接呢?

<?php echo "<a href=\"http://www.webjx.com\">www.webjx.com.com</a>";?>

  如何创建一个有style的连接呢?

<?php echo "<font style=\"color:blue;font-size:10px;font- family:verdana;\">Free Scripts By: <a href=\"http://www.webjx.com.com\" target=\"_blank\" title=\"Free Scripts By: webjx.com\">http://www.webjx.com<;/font></a>";?>

  "echo"是用来显示输出的。

  三:如何实现分页:

  如果好多内容在你的页面中这时我们就考虑用分页形式来实现显示了。

  简单的分页代码:

<html>
<head>
<title>webjx.com</title>
</head>
<body text="#000000">
<center>
<table width="500" border="3">
<tr>
<td width="140" height="400" valign="top">
<p align="center">
<a href='index.php'>home</a><br />
<a href='index.php?p=Page1'>page 1</a><br />
<a href='index.php?p=Page2'>page 2</a><br />
</p></td>
<td width="360" height="400" valign="top">
<p>
<?
function index()
{
echo "<p align=center>Welcome to this tutorial<br />Here you can find funny
tricks</p><br /><br /><br /><br /><br /><br />"; }
$choice=$_GET['p'];

switch($choice)
{
case "Page1":

echo "<p align=center>Page1 text, img and so on here</p>";
break;

case "Page2":

echo "<p align=center>Page2 text, img and so on here</p>";
break;

default:
index();
}

?>

</p>
</td>
</tr>
</table> </center>
</body>
</html>

  以上文件必须保存为index.php

  高级分页的代码

转自:http://www.jzxue.com/Html/php/062918471.html //很详细很实用

posted @ 2013-01-15 17:51  stma  阅读(137)  评论(0)    收藏  举报