phtml, php5 php3.. do not render on Apache webserver solution

Php has more extension than the customary ‘.php’.
If you are using for some reason the extension other than php, then you have to let Mr Apache that you intend to treat .phtml just like that of php files.
You can accomplish this using a simple .htaccess file that sits on the root folder of your website.

AddHandler application/x-httpd-php .php .php3 .php4 .php5 .phtml .html .htm

Yup that should take care of the mess.

Fatal error: Using $this when not in object context in PHP

Whenever you got this error check the following:

1. Make sure the $this-> is used inside the object and referring to the class’s and inherited non-static members.

2. Make sure the called members of the object are properly addressed as static or member/function variables

Do you know the different different post types?

Here is an example for the second one.

Assume you have the following object


class Example
{
   function getExampleText()
   {
      return "Example Text";
   }
   static function getStaticExampleText()
   {
      return "Static Example Text";
   }
}

While accessing, if the code tries something like this one,

$example = new Example();
Example::getExampleText(); //Trying to access non-static as static

Then you would have the error