There’s a saying that you never know where your next opportunity will come from. Neil Patrick Harris found success early on as the titular star of “Doogie Howser, M.D.” Then, as is normal with many child actors – or actors in general really – he went through a fallow period in his career. Sure there were guest appearances on “Murder, She Wrote” and “Will & Grace” and smaller roles in films like Starship Troopers, but there wasn’t a role that was as substantial as the “Doogie” role that catapulted him into the zeitgeist.

Almost every week you hear another sad story about another child star-gone-bad. Harris has his theory about how he escaped the child actor “curse.”

“I’m just trying to have longevity [in the entertainment industry], and I like to work. Success is great, fame is tricky. People love to ‘find’ someone they don’t know and become really intrigued by them. They find out everything about them, and then a saturation point is reached and they go find someone else. The more famous you get, the more vilified you can become,” he says. “That’s a very tricky thing when you’re a teenager and you’re being recognized for stuff and then it goes away. I think that’s where the tailspin usually happens. I was always kind of weirded out by the teen magazine world. I like to work a lot. If anything, I was happy to keep plugging away.”

Then along came a crazy little screenplay called Harold & Kumar Go to White Castle. In the script, there was a part written for Neil Patrick Harris, the actor, albeit a highly stylized, cartoonish version of NPH.

While he does agree that the NPH character in Harold & Kumar is larger-than-life, he doesn’t agree that it’s necessarily NPH: Neil Patrick Harris – the big star.

“I don’t know if I agree with that. In the [Harold & Kumar] movies, my character’s sort of in his own little world. He acts like he’s famous, but he doesn’t act like he’s ‘the shit.’ I tried to play him in this movie as more like Dean Martin. Like after the musical number, I had them bring me a martini and I’m toweling off my neck and all my inflections were very specific.”

Harris goes on to explain about the first script, “I was so confused. I met with them [writers Jon Hurwitz and Hayden Schlossberg] after the script was being submitted for actors to read, and I was in the movie and had no knowledge of any of it. I had no idea I was mentioned in the movie. I didn’t want to be portrayed as the ass of the joke, so I was initially concerned. I met with them, and they were such nice guys with a plan for the whole film. They wanted to be more reverential than “schticky.” I trusted them-ish. I had it put in my contract that any other additional dialogue that had to do with me or my scenes would have to be approved by me once I signed on. Sometimes in movies, they’ll hire new writers to take a pass at a script and then suddenly there might be all these disparaging ‘Doogie Howser’ comments that I would have no control over.”

The Harold & Kumar movies are very subversive, quite worthy of their R ratings. Where would Harris draw the line?

“That’s a hard question. I never would have thought that I’d be smoking crack or forcing myself upon strippers or saying some bad, bad things. I don’t know where the line gets drawn anymore. That is what’s so entertaining about the writers. Jon [Hurwitz] and Hayden [Schlossberg] are so super blue and low-brow yet nice people who can figure out how to make it hardcore but with a heart.”

A good example of the Harold & Kumar subversiveness is the explanation of him being alive after seemingly being shot to death at the brother in the second movie. A Very Harold & Kumar 3D Christmas explains that he’s kicked out of heaven by Jesus for being a bigger player than Jesus.

“That was fun. The guy that played Jesus was really funny too. And I thought it was smart too that NPH’s version of the pearly gates is a nightclub – an early ’90s nightclub with German techno music,” he says.

The rest, as another saying goes, is history. His Harold & Kumar role led to his role as Barney Stinson on “How I Met Your Mother” which has garnered him four Emmy nominations and counting. He has also showed off his musical chops on “Glee,” which also earned him that Emmy, and he’s one of the most in-demand awards show hosts around evidenced by his recent Tony and Emmy hosting gigs. Not so coincidentally, one of his big scenes in the new Harold & Kumar film is a huge Broadway-type number.

“It was pitched to me as a sort of Bing Crosby Christmas TV special with Kelly Ripa. The two of us were going to be in our living room with our eight kids in our sweaters singing ‘Little Drummer Boy.’ Then Kelly was filming in Prince Edward Island the very week that I was available to film, so she couldn’t do it. Rather than find someone else to fill her shoes, it was turned into a solo performance. Then it became a bigger Rockette-style performance.”

Though he certainly has the chops, he’s still a little surprised at how much singing is part of his on-stage persona now.

“I’m game for that stuff. I like weird variety show stuff like singing and magic but it’s sort of a talk show curse. ‘Will you sing a song for us?’ ‘Will you do a magic trick for us?’ Because once you do it once … I didn’t go to a music conservatory or anything, but I grew up in a musical family and I took voice lessons. I’m very lucky where I can do a ‘Glee’ episode and sing a song that people remember, but I actually recorded it in a recording studio for an hour and a half and I never had to sing it again. That’s a far cry from the people who are on Broadway and have to sing every night for two hours a night. You can’t talk during the day. You’re constantly humidified. You’re hydrated like crazy. You’re going to the throat doctor all the time.”

As of yet, he “hasn’t been approached to do another ‘Glee’ episode. Plus everything I do has to be approved by CBS and Fox since I’m under contract with both, so that limits my options. The ‘Glee’ thing was great since it’s a Fox show, so there was that tie-in.”

Especially in Hollywood, but in life in general, it always helps to have some luck to go along with talent.

“I’m a very lucky actor. A lot of actors who are on TV work 16 hour days everyday to say things like ‘Boss, I found a piece of evidence I think you ought to see.’ To be [my character] Barney on ‘How I Met Your Mother’ of all shows with the great, hilarious, random flashbacks is my bread and butter.”

If you do happen to see him on the street and recognize him, there’s a world of difference between the real-life NPH and the NPH portrayed in the Harold & Kumar movies. The real life NPH is married with 1-year-old twins while the Harold & Kumar version of NPH will steal your car and snort drugs off your backside. While plugging away at his busy schedule, he probably has the right magic tricks up his sleeve to ensure that he continues to be recognized for his talent and not his fame.

A Very Harold & Kumar 3D Christmas releases in theaters Nov. 4.