Great cars and if your good with fixing cars and have all the right tools. You also have the internet to fix a lot of problem in question. You'll just need plenty of time to review and make sure you have all necessary parts then it shouldn't be a problem. If you have to rely on going to the stealership or auto mechanic. It can become very expensive real fast.
Owning a 540i some common problems are the Cooling System, Timing Chains and Guides, VANOS, alot of electrical/electronic problems and the valve cover gaskets. But the car is fun to drive. Great car if you are a DIY'er and have time on hand.
Worth it if you can keep up with maintenance. Most problems are easy to fix and you can find DIY on youtube.
The meaning of BMW is in the Netherlands: Blijf Maar Werken... Its means: stay just wroking....... Beceause if the bmw is broken its cost allot and if it broks once it will happen more.
if you have a second hand one it is a pain, my friend got a 3 series, too much electric problems his 1000 watt amp shut his car down.
There are not bad cars if you are a handy person or know a good mechanic. That is a feature of the car that it shut it self down before the battery gets dead. With a $30 cable you can diagnostic the car with software online.
I have 2002 325i. It still runs great and I'm able to slot of the fixes myself. Parts are readily available (much cheaper in the US) and their are empty of diys on YouTube. Don't be scared.....they are manageable.