What are some recommended low-cost or free web hosting providers that support PHP and MySQL for hosting PHP applications?

When looking for low-cost or free web hosting providers that support PHP and MySQL for hosting PHP applications, some recommended options include 000webhost, AwardSpace, and InfinityFree. These providers offer free hosting plans with support for PHP and MySQL databases, making them suitable for hosting PHP applications without breaking the bank.

// Example PHP code snippet for connecting to a MySQL database using PDO
$host = 'localhost';
$dbname = 'database_name';
$username = 'username';
$password = 'password';

try {
    $pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
    echo "Connected to database successfully";
} catch (PDOException $e) {
    die("Could not connect to the database: " . $e->getMessage());
}