Belirli bir site için belirlenmiş bir sınıf var. Bu sitede ben veritabanından veri almak ve bir diziye bu verileri depolamak için farklı işlevlere sahiptir. Ben veri almak ve html içine biçimlendirmek ve veritabanından verileri içeren html döndürür aynı sınıf içinde diğer işlevlere sahiptir.
Örneğin ...
function GetUserProfile($userID){
$query = 'SELECT * FROM users WHERE userID='.$userID;
.......
blah blah blah
.......
$user = mysqli->fetch_assoc();
return $user;
}
function FormatUserProfile($user, $showDesc = false){
$profile = '< h1 >'.$user['userName'].'< / h1 >';
if($showDesc){
$profile .= '< div >'.$user['description'].'< / div >';
}
return $profile;
}
...
So if i had a function to solely gather information, and another function to solely format that gathered information. Mainly because I will be showing the same data on different pages, but Different pages show different data, like a search would only bring up the users name, where as the users profile page would bring up the username and the description for example.
Bu iyi bir uygulama mı, yoksa bunu yapmak için daha iyi bir yolu var mı?