A problem in my PHP MVC project

I tried to make a project based on a tutorial and use PHP MVC architecture. I have provided my project files. I have made a router that can redirect any URL to its controller. At this stage of my project, all URLs are directed to the home controller and then to the index page. When I test it, it shows a blank page. What is wrong with my code? Please guide me.

Blank php pages can be caused by -

  1. A php parse/syntax error.
  2. A fatal php runtime error that occurs before the point where any output is sent to the browser.
  3. Code that doesn’t produce any output.
  4. Code that is redirecting all over your site, with php’s output_buffering turned on, so that any output is discarded.

For items #1 and #2, you need to set php’s error_reporting to E_ALL and set display_errors to ON, in the php.ini on your system, so that php will help you by reporting and displaying all the errors it detects. For item #2 only, you can temporarily put these settings at the start of your php code, but it is better to keep them in the php.ini so that they can be set at single point.

For item #3, this is typically due to a logic mistake, i.e. code that doesn’t do anything for a particular input condition. You would need to go though the code and add debugging statements to output messages to let you know what execution path the code is taking, then once you find where the problem is at, correct the logic so that the code does something useful to let the visitor know what it is that they should do to cause the page to operate as intended.

For item #4, while you are editing the php.ini on your system for the php error settings, set output_buffering to off, so that you will be able to see any output from your code or any non-fatal php runtime errors that occur prior to any redirect. Also, generally, the only redirect you should have in your code is upon successful completion of post method form processing code, and the redirect should be to the exact same url of the current page to cause a get request for that page.

Sponsor our Newsletter | Privacy Policy | Terms of Service