Compared to the Spearman, the Phalanx gets +1 strength and receives +25% defense in hills.
Phalanxes are the ultimate anti-horse unit for quite a long time. Stack them with Axemen and you can effectively attack cities - with both units. Be sure to leave at least one Axeman and Phalanx undamaged per stack to prevent retaliation.
Axemen are still effective against Phalanxes, and you can take down a stack of them fairly easily. If they're using Axemen themselves, bring Chariots as well.
Compared to the Axeman, the Phalanx gets +100% defense vs. Chariots.
The defensive bonus covers the usual weakness of Axemen, allowing them to potentially raid cities with just a single-unit stack. Promote them in Shock promotions, or take some Chariots to have the upper hand against other Axemen, or City Attack promotions to capitalize on the city-attack-ability.
Axemen will be an even match against Phalanxes, but a shock promotion will give those Axeman the upper hand - unless they're using it themselves. Try to force them onto bad terrain if they're attacking you - cover the hills with Archers.
Phalanxes were well-trained citizen-soldiers of ancient Greece. Armed with spears and durable armor, they fulfilled the heavy infantry role in most engagements. Phalanxes are tightly packed groupings of eight or sixteen rows of soldiers, who move and attack in unison, scattering less densely organized enemy forces. Phalanxes worked well against the forces of the day, but broke down when facing more mobile and well-trained professional soldiers. The Roman legions victory over the Macedonian phalanx at Pydna in 168 BC effectively ended the phalanx's battlefield usefulness.