What are the advantages and disadvantages of using a CMS versus a custom PHP script for content editing?

When deciding between using a CMS or a custom PHP script for content editing, it's important to consider factors such as ease of use, scalability, and customization. A CMS like WordPress or Joomla may be easier for non-technical users to manage content, but it may also come with limitations in terms of customization and performance. On the other hand, a custom PHP script allows for complete control over the editing process and can be tailored to specific needs, but it requires more technical expertise to develop and maintain.

// Sample PHP code snippet for custom content editing script
<?php
// Connect to database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

$conn = new mysqli($servername, $username, $password, $dbname);

// Fetch content from database
$sql = "SELECT id, title, content FROM articles";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Output data of each row
    while($row = $result->fetch_assoc()) {
        echo "ID: " . $row["id"]. " - Title: " . $row["title"]. " - Content: " . $row["content"]. "<br>";
    }
} else {
    echo "0 results";
}

$conn->close();
?>