PHP is a language that has been created with a focus on generating dynamic HTML pages, and although it has evolved into a general-purpose language, it has not incorporated the best choice of tools needed for generic applications - thus, it is possible to create a P2P network and implement existing network protocols in PHP, but because it is not the best tool for this, it was not done. It would be dangerous to speculate why this is happening here, because I couldn’t be objective. All that is needed to implement any network protocol is that there is an API for pure sockets, and a way of manipulating bytes and bits - the rest is a matter of how practical it is, in language syntax to write code concise, clean, with good practices of security and easy maintenance.
As for smart Contracts, here’s another story - blockchains that allow smart Contracts do this with a specific bytecode, which runs on the nodes of the chain, and has one or more languages specifically created to create smart-Contracts in that chain (the exception I know of is the EOS that uses C++). But if you take Ethereum, for example, which is probably the most popular blockchain for smartcontracts - it has two or three distinct languages, but its own, for creating smartcontracts - the most popular being one that is more like, but not Javascript (solidity) and another similar, but otherwise, Python (Vyper).
As for the first part, from "how one peer finds another" - in the configuration of each P2P project there is a list of "initial partners" - it’s even a form of centralization - but nothing prevents code fonts from changing that initial list of known partners, and anyway, They’re just a setup. And, among the calls that are made automatically to the other nodes, there are always calls to search other nodes partners, and an algorithm well done is repeating these calls to choose nodes more distant, different, but with a good response time - this way, information about distant nodes is propagating and the network maintains its decentralized character, even each node "zeroed" starting with a fixed list of partners.
Now - if you’ll allow me to draw a little fire out of the answer text: learn Python. It’s worth it if you’re after that sort of thing.
– jsbueno