小型 Twitter 的系统 源碼+註釋,PHP
?
<?phpsession_start ();include_once ("header.php");include_once ("functions.php");?><meta http-equiv="content-type" content="text/h<em>8本文来源gao.dai.ma.com搞@代*码(网$</em><pre>搞代gaodaima码
tml; charset=utf-8″ />
List of Users
<?php$users = show_users ();$following = following(1);if (count ( $users )) { ?>
” . $key . “ | ” . $value;//顯示id對應的值也就是value if (in_array ( $key, $following )) {//檢查key是否在following中 然后根据状态显示不同的值显示不同的信息 生成不同的指向action的链接 echo ” unfollow “; } else { echo ” follow “; } echo “ |
<?php} else { ?>
There are no users in the system!
<?php}?>
<?phpsession_start ();include_once ("header.php");include_once ("functions.php");/** 处理follow动作 */$id = $_GET ['id'];//获取get 方法传来的值 $_POST是post$do = $_GET ['do'];switch ($do) { case "follow" : follow_user ( $_SESSION ['userid'], $id ); $msg = "You have followed a user!";//设置信息 break; case "unfollow" : unfollow_user ( $_SESSION ['userid'], $id ); $msg = "You have unfollowed a user!"; break;}$_SESSION ['message'] = $msg;//在session中发送信息header ( "Location:index.php" );?>