If we boil an egg which already has a crack on its shell before boiling, it will break and spread into the water. In many cases if we put an egg into hot water it will crack also. So, is there any safe method to boil an egg like that, or should it be fried or cooked in another way?
If an egg is already cracked then it will almost certainly split open when boiled, there's no way to avoid it, it would be best to cook them using another method. Be aware that once eggs are cracked they no longer have protection against microbes, if you don't know how long they have been cracked it may be best to throw them away.
I use Egglettes™ to boil my eggs. You simply crack the egg/s into a silicone cup and place it/them into boiling water. Without wishing to seem like a crappy infomercial (see below), I find it a heck of a lot easier to crack an egg into a cup than I find it to peel eggshells off of a soft-boiled egg.
Obviously it makes no difference if the egg has already sustained a recent crack (from being dropped onto the surface, for example) since you're removing the shell prior to cooking.
For the avoidance of doubt, I am in no way affiliated to Egglettes other than being a customer
You can choose to poach the egg.
The egg is cracked into a cup or bowl of any size, and then gently slid into a pan of water at approximately 75 Celsius (167 °F) and cooked until the egg white has mostly solidified, but the yolk remains soft. The "perfect" poached egg has a runny yolk, with a hardening crust and no raw white remaining.
I don't have any experience with this but I would imagine you could cook it until the yolk hardens along with the whites.
You can boil cracked egg safely just use 2 table spoons of white vinegar. Put White vinegar in boiling water and then gently put the egg in the water and let it boil. Egg will not come out of its shell. You can also make egg poach.Click here to understand about egg poach
If the egg's been cracked for a while, just throw it out. Even though the boiling process should kill anything growing in it, good sense says it's not worth the risk. If the egg gets small cracks when you put it in the water or while cooking, it's perfectly fine. In my experience, the heat will quickly make the outer layer of white solidify as it cooks, which will lock everything else inside, crack or no. The worst I've ever seen happen from cooking an egg that cracked early on is that little bits of white escape and get cooked in the water, giving it a cloudy look. I've eaten many eggs that cracked while cooking and never had any problems.