This will be relatively brief as a follow-up to the previous discussion and it will predominantly focus on a particular part of how price to earnings ratios (PEs) are used to value stocks. I will confess that I have not read a finance textbook in some time so the following is more what I have observed and what economic theory would dictate than any particular theory that is widely accepted.
When you look at a stock quote page on any website such as Bloomberg, Yahoo! Finance, Marketwatch, or whatever brokerage account you use, you will see an estimate of the company's PE ratio. More often than not, this is based on the earnings per share for the prior one year as reported on a GAAP basis. Often when you hear an analyst on TV talking about a stock that they like, they will either use this prior one year number or use analyst estimates of the next fiscal year. Either way, it is almost always a one year snapshot. The market in general is usually somewhere between 10 and 20 times earnings, though individual companies vary widely.
Now, you might be asking yourself "Why would I pay 10-20 times a year's worth of earnings for a company?". This, on its face, is a good question. It does seem a bit absurd. However, implicit in our acceptance of any given PE ratio is the assumption that the current year's earnings per share are a good point for estimating future years' earnings. Indeed, stocks, more or less, conform to the discounted future earnings (or the related dividends and cash flows) of a company over a number of years. Take a current year's earnings, grow them at 8% per year, appropriately discount them for inflation or a risk free rate of return (people do both), sum up, say, 10 years and you get a number that makes considerably more theoretical sense.
Now, some interesting implications of this can be found in real life examples. Take Bristol-Myers Squibb (BMY) for a moment. In 2000, it traded at about 25 times earnings, which was not absurd given its growth rate in the 1990s. This was true of nearly all pharmaceutical stocks. However, collectively, their pipelines dried up and their patents expired, leading to earnings stagnation. Despite having a reasonable PE often around 13-17 times current year earnings, the stock first plunged and then simply faltered. This was repeated across the pharmaceutical industry.
Of course, the same thing happens the other way too. Seemingly unreasonable PEs like Google's (GOOG) can be made reasonable by truly extraordinary growth rates. A company can trade at 60x earnings if it is about to grow 35% a year or more for five years straight.
Another implication of this concept is when a company is poised to have an explosive year due to a big one-time payment or government contract. It may have a very low PE ratio due to these artificially expanded earnings. However, it will be a rude surprise for you indeed if you buy based on that and the company's earnings return to earth a few years later 80% below that inflated level. The discounted sum of its earnings over ten years (or whatever interval you choose) will be far less than you might expect.
This actually also relates to my prior post on bad trend analysis. You have to do more homework than just extrapolating out the past five years' average growth rate over the next decade for a company. You need to do good qualitative analysis to determine whether or not that makes sense or else using a particular PE as a rationale for purchasing a stock will not be fruitful.