帮助OOP类及其成员 [英] Help with OOP class and its members
问题描述
你好,
我有一个非常小的登录脚本,我觉得有点乱。我想清理它,并以正确的方式做到这一点。我的脚本发布在下面。我想帮助理解会员,如果有的话我应该申报。
[PHP] class登录
{
功能登录($ account,$ operator,$ password)
{
}
函数getUser()
{
ob_start();
if(isset($ account)&&($ operator)&&($ password))
{
$ password = md5($ password);
require_once(" database.php");
$ db = new Database();
$ result = $ db-> query("");
$ count = $ db-> count() ;
if($ count == 1)
{
foreach($ result as $ key)
{
$ level = $ key [''level''];
$ name = $ key [''last_name''];
}
$ _SESSION [''name''] = $ name;
$ _SESSION [''user''] = $ user;
$ _SESSION [''level''] = $ level;
header(" location :index.php?id = 6");
}
else
{
header(" location:index.php?id = 1");
}
}
ob_end_flush();
}
} [/ PHP]
Hello,
I have a very small login script that I feel is kind of a mess. I would like to clean it up and do it the correct way. My script is posted below. I would like to have some help in understanding what members, if any I should declare.
[PHP]class Login
{
function Login($account,$operator,$password)
{
}
function getUser()
{
ob_start();
if(isset($account) && ($operator) && ($password))
{
$password = md5($password);
require_once("database.php");
$db = new Database();
$result = $db->query("");
$count = $db->count();
if ($count == 1)
{
foreach($result as $key)
{
$level = $key[''level''];
$name = $key[''last_name''];
}
$_SESSION[''name''] = $name;
$_SESSION[''user''] = $user;
$_SESSION[''level''] = $level;
header("location:index.php?id=6");
}
else
{
header("location:index.php?id=1");
}
}
ob_end_flush();
}
}[/PHP]
推荐答案
account,
operator,
密码)
{
}
函数getUser()
{
ob_start();
if(isset(
password)
{
}
function getUser()
{
ob_start();
if(isset(
这篇关于帮助OOP类及其成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!