Tener de ou tener que?

I have learned that “to have to” is tener de, but I have seen it as tener que as well. can it be either or does it depend on the circumstances?

In Portuguese we say “ter de” and “ter que”, but they have different meanings. “Ter de” expresses obligation, duty, necessity, wish, but very often it is wrongly replaced by “ter que”. Example: “tenho de ir pagar a conta da luz”
“Ter que” has the meaning of “having things to do” and the central meaning depends on the verb that follows “ter que”, for example: “Tenho muito que fazer.” ( I have a lot of things to do), “Ele não tem que comer” (he has nothing to eat).

More examples and explanations here: Dúvidas sobre o «ter de» e o «ter que» - Ciberdúvidas da Língua Portuguesa

Interesting, so this usage is different from usage in Spanish. Thanks!