Foreign travellers holding connecting tickets to pass through China are exempt from visa requirements provided they stay in the transit area of the airport for a no longer than 24 hours.
Some can only be applied for outside China, some both, and one 'visa equivalent' – the temporary residence permit - can only be obtained inside China
The regulations include a number of factors such as your nationality, whether you have family in China, and whether you were previously a Chinese citizen, and of course which type you are applying for, as well as that, each issuing office has some discretion in how they implement the regulations. This makes it impossible to explain here exactly what will happen, or to provide any certainties. However, these guidelines will be relevant to most situations.
The regulations are not normally applied to their fullest extent but at any time the government may issue a directive to apply the regulations more rigorously against an individual, to applicants from certain nations, or when special events are taking place such as the Olympic Games. Thus, at any time you might be asked to supply full travel bookings, show a minimum amount of funds, or have invitations from Chinese persons or organisations.
Visas can be issued for various durations; immediate or later start dates, and allow one, two (dual), or multiple entries. Any exit from the mainland of the PRC, including to Hong Kong and Macau will require that you have a valid entry to the mainland to permit you to re-enter. Otherwise you will need to apply for a new one at a consulate (or equivalent in Hong Kong) before entry is permitted.
The Chinese visa is usually a paper sheet glued into your passport but it can occasionally be a rubber stamp.
Nationality Makes a Difference
Like most countries, China applies has stricter regulations than it actually applies most of the time. It may be that nationals of some countries have been found to overstay more frequently than others, or have a higher incidence of crime, or be nations associated with terror, or simply ones where diplomatic relations are currently strained. It seems that at present, applicants from certain Asian countries are being required to get invitations and show adequate funds.
Visa fees also vary considerably according to nationality.