Sobes.tech
Junior — Middle

What recent projects or tasks have you implemented using pure PHP?

sobes.tech AI

Answer from AI

In one of my recent projects using pure PHP, I implemented a REST API for task management. Without using frameworks, I wrote routing, request handling, and database interaction through PDO. For example, to handle a GET request for the task list, I used the following code:

if ($_SERVER['REQUEST_METHOD'] === 'GET' && $_SERVER['REQUEST_URI'] === '/tasks') {
    $stmt = $pdo->query('SELECT * FROM tasks');
    $tasks = $stmt->fetchAll(PDO::FETCH_ASSOC);
    header('Content-Type: application/json');
    echo json_encode($tasks);
}

I also implemented forms with data validation and sessions for user authentication.