Think the real "risk" to PHP is that the platform becomes irrelevant, not challenges from other languages.
The magic words there are "mobile solution company".
So long as the internet is primarily text based, PHP has a place. Once video over the net goes mainstream and mobile becomes the primary client, the "text based internet" is less interesting.
And re: Rails - the problem there is it's a great solution with nowhere to run. There's an interesting read
here - most people focus on the 50,000 lines to 5,000 lines part. Personally I just read that as a scaling nightmare, that the PHP codebase didn't have. FastCGI is the primarly place to run rails but it's old and buggy code - see
here and
here - on the "stability curve", I'd guess Rails (and other frameworks requiring FastCGI) is around the same mark as PHP 3.x, when you consider the role FastCGI has to play.