Is it common to use PHP for coding websites like online pet shops?

Yes, it is common to use PHP for coding websites like online pet shops. PHP is a popular server-side scripting language that is well-suited for web development tasks, including creating dynamic websites with features like user authentication, database integration, and e-commerce functionality.

<?php
// Sample PHP code snippet for creating an online pet shop website

// Connect to database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "petshop";
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Query database for pet products
$sql = "SELECT * FROM products WHERE category='pets'";
$result = $conn->query($sql);

// Display pet products on website
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        echo "Product: " . $row["name"]. " - Price: $" . $row["price"]. "<br>";
    }
} else {
    echo "No products found";
}

// Close database connection
$conn->close();
?>