As of the Summer of 2017, Philadelphia is in the midst of transitioning to a contactless chip card called SEPTA Key for all modes of public transport. The prior system was complicated, and involved different methods of payment depending on the mode of transport.
Pre-SEPTA Key (through 2017, but soon to be deprecated)
Rapid transit, busses, and trolleys could be paid for using tokens purchased at some (but not all) subway stations, either from a kiosk or from a ticket office, only using cash. For all modes of transportation with a human operator (busses, trolleys, and subway stations that have a ticket office), rides could be purchased on-the-spot using cash, but no change is given, so you need the exact amount. Purchasing tokens in advance provided a slight discount per ride.
Several fare products and passes were offered by SEPTA, mostly catering toward people who commute into the city for work, and are typically only economical if you make a minimum of five round trips per week. Day passes are available but are only economical if you make at least three trips in one day. Tourists and families should consider purchasing an Independence Pass.
Tickets for regional rail can be purchased from ticket counters, although not all stations have ticket counters. Tickets can also be purchased on the train in cash for a premium.
Transfers between subway lines and trolley lines are free at some stations (30th Street, City Hall, 13th Street, and 8th Street). At all other stations, transfer between lines and/or transportation modes (por exemplo, subway-to-bus) requires a "transfer," which is a slip of paper you purchase when entering the vehicle during the leg prior to your desired transfer. It is cheaper than using a token for the second leg. For example, say you want to take a bus to the subway. When you enter the bus, you pay for your fare and then tell the bus driver that you want a transfer, paying the additional transfer fare. The bus driver hands you a transfer ticket, which has an expiration time printed on it (I believe it is at least one hour, but no more than three). You then use that transfer ticket when entering the subway on your second leg. You can also purchase a "re-transfer" when you enter the subway, if you want to transfer to another mode of transportation afterward. However, you may not use more than two transfers in trip. Finally, you cannot use your transfer on a line that is traveling in the opposite direction of where you bought the transfer. This prevents gaming the system by purchasing a transfer to use as your return fare.
SEPTA Key Transition (~2017)
You can still use all of the legacy modes of transport, but SEPTA Key (see below) is now available for use on the subway, busses, trolleys, and some (but not most) regional rail lines.
You can purchase a SEPTA Key card from either an automated kiosk or a SEPTA sales desk, however, since SEPTA is still deploying the system, not all SEPTA Key kiosks are configured to sell new cards. You should check SEPTA's website for a list of which stations sell which products. The website says that Key cards will be sold for $4.95, however, when I purchased mine from a kiosk it was free. The kiosk required me to fill it with a minimum amount of cash (I believe it was $20) into what it calls a "Travel Wallet." This amount is automatically debited every time you use the card in place of a token or transfer. Unlike the old token kiosks, the new SEPTA Key kiosks accept both cash e major credit cards.
You can set up your travel wallet to have auto-reload from a credit card, but the SEPTA Key website is very buggy, and people have had a lot of difficulty configuring this feature. SEPTA is currently in the process of redesigning the website.
You can also load fare products like day passes onto a SEPTA Key card.
For stations with SEPTA Key kiosks, you can also buy a "Transit Quick Trip" ticket, which is a paper ticket that works just like a token used to, but costs more than a token or using a Key card with a travel wallet.
Valid transfers are automatically determined and purchased by SEPTA Key, so you do not need to explicitly purchase a transfer anymore if you have a Key card.
SEPTA Key (The Future)
The SEPTA Key card is also a MasterCard. As of the time of this writing the feature is not fully functional, but in the future you will be able to use the card as a debit card, deducting cash from your travel wallet. So, even if you are a tourist and don't know how much money to put in your travel wallet, you can always use any remainder after your trip by spending it like a regular debit card.
Eventually, SEPTA Key will also be deployed on all regional rail lines.