Do buttons/levers above rails prevent zombie pigmen from spawning?
No, buttons do not affect mob spawning
The commenter probably misremembered that mobs cannot spawn if there is no air block. This is just false.
Mobs can spawn in blocks without a hitbox (and carpets) without any issues. They could so for quite a while now (maybe even always). Note that prior to 1.8 the spawning algorithm required an actual air block to start in, but mobs could always spawn in hitboxless blocks.
To test this, I used a superflat world with the following generator:
3;minecraft:bedrock,3*minecraft:stone,5*minecraft:sandstone,4*minecraft:stone_button:5;2;
minecraft:stone_button:5
is a floor button, but the orientation doesn't matter for this. I put 4 layers buttons there. The world looks pretty trippy:
A quick /time set 18000
and mobs start spawning almost immediately, even though there are no solid surfaces not covered in 4 layers of buttons.
This is also true for buttons over rails:
3;minecraft:bedrock,3*minecraft:stone,5*minecraft:sandstone,minecraft:rail,minecraft:stone_button:5;2;
Note: While these are overworld mobs, I have no reason to assume that it'd be any different for zombie pigmen, seeing that they don't follow any special spawning conditions.
For anyone wondering, mobs can not spawn on buttons in 1.9. The previous answer was from 2015, before 1.9 was released.
According to snapshot 15w46a for update 1.9 that was released in 2016:
Mobs can no longer spawn inside blocks that block movement but are transparent, such as leaves.
Mobs can no longer spawn in blocks containing rails, powered rails, detector rails, or activator rails.
Mobs can no longer spawn in blocks containing buttons, tripwire hooks, pressure plates, levers, redstone torches, redstone repeaters, comparators, or redstone dust.