I have a page that retrieves user data and displays that data on the page. My code works perfectly fine, but I am having trouble understanding when to use OOP for web development. My current page is very simple, and my understanding is that OOP consumes a lot of processing power for creating objects. Should a simple page like this require the use of OOP?
<?php
session_start();
require $_SERVER['DOCUMENT_ROOT'] . "/connection.php";
if ($_SESSION["id"] != ""){
$result = $db->query("
SELECT `Username`, `Image`, `FirstName`, `LastName`, `Type`
FROM Users WHERE `id` = '{$_SESSION['id']}'
");
if ($result->num_rows == 0){
$switch = false;
} else {
$resultSet = $result->fetch_array();
$avatar = $resultSet["Image"];
$account_type = $resultSet["Type"];
$username = $resultSet["Username"];
$fName = $resultSet["FirstName"];
$lName = $resultSet["LastName"];
$id = $_SESSION["id"];
$switch = true;
}
}
?>
Afterwards, the information is displayed in the HTML. For example, when I want to display the name I just echo it out. Like so echo "<p>$fName</p>"; should this approach be changed in to an objected oriented approach instead? Or is my design suitable as it is?