ORLANDO, Fla. — If Mario Hezonja played all the time the way he did Wednesday, he never would have been shown the door by the Magic in the first place.

Knicks coach David Fizdale kept his promise and it paid off — at least for Hezonja. In January, Fizdale guaranteed Hezonja that in the Knicks’ last game in Orlando — which happened to be Wednesday — no matter what the situation, he would start him. Hezonja had missed the Knicks’ initial November encounter here with food poisoning.

In his first game against the Magic in an opponent’s uniform, Hezonja dropped in a career-high 29 points, keeping the Knicks close before they lost 114-100 at Amway Center.

“Super Mario,’’ Fizdale crowed. “I’m just really happy for him. I told him: Perform for Orlando. He came out and showed what he can do.’’

And so he did, despite fouling out with 3:40 left after playing with five fouls for most of the fourth quarter. Hezonja had told Fizdale to let him stay in.

“He played the best game of his career,’’ former Magic teammate Evan Fournier said. “Very aggressive.’’

It has been a mostly inconsistent season for Hezonja, who has had some wonderful moments, including two superb appearances in the Knicks’ season sweep of the Lakers, but hasn’t displayed enough of the artistry he showed Wednesday as an inside-outside threat.

“I have to control my emotions more,’’ Hezonja said. “There was a lot of emotions out there, but thank God I lined them with basketball.’’

Before the game, Hezonja admitted, “This is a game I cannot miss,” so it was no surprise he was attacking and playing energetic defense from the get-go. But he was just 3-for-10 — even blowing two layups — in the first half before he poured it on in the second half.

During one stoppage as Hezonja shot free throws, a fan yelled, “Mario, you suck.” Hezonja answered back, “Are you watching the game?’’

With five games left, Hezonja’s start disrupted Fizdale’s new experimental arrangement of starting the double-tower tandem of Luke Kornet and Mitchell Robinson. But it was worth it.

The 6-foot-9 Croatian combo forward was cheered during player introductions, and when it was over, he had banged in 11-of-20 shots with nine rebounds and five assists even as the Knicks fell to 15-63. The Magic (39-40) moved into a seventh-place tie with the Nets in the Eastern Conference.

Hezonja, who played three seasons with the Magic as a high lottery pick, still has a place in Orlando and indicated he would come to a playoff game here should the Magic, who have missed the playoffs six straight years, make it.

“They really stepped up this year,’’ Hezonja said. “I’ll be the first fan watching playoff basketball in this city.’’

Before the game, Hezonja spoke thoughtfully about Orlando’s fans.

“The reception, I don’t give a damn,” Hezonja said. “But I want to thank them for the first three years. We were like mostly down with many unfortunate circumstances that were happening in organization and the mess we were. I still have a lot of messages, a lot of texts on my Twitter feed full of Magic fans.”

This was Hezonja’s 21st start for the league-worst Knicks — the most memorable coming March 17, when he blanketed LeBron James and blocked his shot in the final seconds to preserve a victory. Hezonja did not play Monday against the Bulls, another rare victory.

Because of the team’s ultra-youth movement, it’s unclear if Hezonja will see the floor much the rest of the way.

Knicks general manager Scott Perry was part of the Magic’s managerial team that selected him fifth overall in the 2015 draft and surprisingly signed him with most of the Knicks’ mid-level exception last summer to a one-year, $6.5 million deal.

Hezonja’s chances of sticking next season appear slim, but Perry has a longtime fondness for the skilled combo forward, who is shooting 39.8 percent.

Nights like Wednesday give pause.