Hernandez finished the day with three hits and three RBIs. He singled to drive in Cedric Hunter in the fifth and doubled to score David Lough in the seventh. Hernandez scored the game-winning run on a safety squeeze by Freddy Galvis later in the seventh.
The Phillies scored twice in the fifth inning against Ken Giles, who is Houston's likely closer. It was the first time Giles faced the Phillies since they traded him in December.
Phillies right-hander Jeremy Hellickson, who is in line to start Opening Day, allowed no hits and three walks and struck out six in five scoreless innings.