PHP started out as being a pre-processor for SGML documents. All PHP code is contained inside SGML program instruction tags. PHP has never changed this, so however it has developed it is still, in essence an SGML preprocessor because even today, all PHP code is contained in SGML PI tags.
This means that your class files, etc. all begin with opening a PI tag....
Now that doesn't mean there aren't some really cool niches for PHP. Using something like PL/PHP and the native XML support in PostgreSQL, you could do some pretty cool stuff. Similarly for lightweight web development there is simply not a better language.
But when you are building a framework where logic may have to be used in non-SGML environments, PHP is a very poor choice. This means when you choose PHP you are limiting yourself to web environments only. Better choices where there is any possibility of escape from the web include Perl, Python, and Ruby.