STANFORD, Calif. (AP) -- It took a trick play to get Stanford's offense finally going this season. Afterward, it was as if the floodgates had opened.

Kevin Hogan connected on a 53-yard flea flicker to Michael Rector to highlight a three-touchdown night as Stanford bounced back from a disappointing loss in its season opener to beat Central Florida 31-7 on Saturday night.

"You never want to allow it to creep in that, 'Oh no, we can't reach the end zone,'" Hogan said. "It was almost like breaking the ice. I think everybody kind of settled in after that and felt comfortable."

More from FoxSports

The deep strike to Rector was Stanford's first touchdown of the season. Hogan added a 7-yard touchdown pass to Christian McCaffrey and a 93-yarder to Bryce Love in the second half as the Cardinal (1-1) avoided their first 0-2 start since 2006.

Hogan finished with a career-high 341 yards, including three passes of more than 40 yards.

"Once we got into a rhythm offensively it was fun to watch," coach David Shaw said. "We did try to do some different things game-plan wise to get some guys in space. We have some speed on this team."

The Knights (0-2) struggled to generate any sort of offense with starting quarterback Justin Holman leaving early with an injury. Freshman Bo Schneider came in and went 7 for 19 for 46 yards with an interception.

"There were a lot of guys that could have made plays but didn't make them," coach George O'Leary said. "As they said, films don't lie. We got to go back and look at that and continue to try to get the best 11 on the field."

After being held to six points in a lackluster opener, Stanford's offense finally broke through late in the first half with help from a trick play. Hogan handed the ball to Barry Sanders, who flipped it back to the quarterback. Hogan then launched a deep pass to Rector, who got past the defense for the first score of the game.

Conrad Ukropina added a 52-yard field goal in the final minute of the half.

Hogan's 42-yard pass to Love set up the short touchdown pass to McCaffrey in the third quarter. Hogan then hit Love again on a short pass on a third-and-20 and Love raced past the Knights defense for the score that made it 24-0.

While Hogan got the passing game going, the Cardinal struggled to run consistently for a second straight week. McCaffrey gained just 58 yards on 20 carries and the team finished with 130 yards on the ground with 40 coming on a late drive capped by Sanders' 20-yard TD run.

The defense was dominant, holding Central Florida off the scoreboard until Tyler Harris threw a 36-yard TD pass to Tre'Quan Smith with 1:22 to play.

The Cardinal easily handled the untested Schneider, who made his debut after Holman hurt his hand when he hit a helmet on Central Florida's first drive. O'Leary said Holman's hand was in a splint and he did not know the severity of the injury.

"It's tough, but the program that we have here, it's next man up," tight end Michael Campbell said. "That's just how things go here."

The Knights had just one productive drive until the late score but that ended in the second quarter when William Stanback fumbled inside the Cardinal 40. Four plays later, Hogan hit Rector on the flea-flicker.

Stanford also lost a key player when defensive lineman Aziz Shittu was ejected for targeting in the first quarter on a hit to the head of running back Taj McGowan.