1

I am trying to make an interactive php website using MVC framework and on a MAMP server, I am at the first steps of this. I am using the following code to access a different page which has a __construct() function to echo some text... but the index.php returns a blank page...

init.php:

<?php
require_once 'core/App.php';
?>

the other page code is:

App.php:

<?php
class App {
public function __construct() {
   echo 'some text';
     }
}

my index.php is as follows:

<?php
require_once '../app/init.php';
$app = new App;
?>

and I looked at the different solutions and have tried many but still not working. like adding ROOT or DIR and even FILE, knowing that my version of PHP is 7.

help is appreciated... thank you...

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Sumaia99
  • 11
  • 2
  • 1
    Blank page, try http://php.net/manual/en/function.error-reporting.php – Funk Forty Niner May 07 '16 at 15:25
  • Take a look in your apache logs. Where that is will depend on your setup. For me (on a mac) it's /var/log/apache2/error_log. On my linux servers it's /var/log/httpd/error_log – Nathan Edwards May 07 '16 at 15:31
  • [`is_readable()`](http://php.net/manual/en/function.is-readable.php) or [`file_exists()`](http://php.net/manual/en/function.file-exists.php) or else – Chay22 May 07 '16 at 15:46
  • @NathanEdwards I have checked the logs folder in Mamp, turned out to have some errors, the errors are as follow: [Sat May 07 17:20:46 2016] [warn] Init: Session Cache is not configured [hint: SSLSessionCache] , [Sat May 07 17:30:17 2016] [error] [client 127.0.0.1] File does not exist: C:/MAMP/htdocs/favicon.ico , [07-May-2016 13:26:17 UTC] PHP Fatal error: require_once(): Failed opening required 'core/Controller.php' (include_path='.;C:\php\pear') in C:\MAMP\htdocs\project3da\mvc\app\init.php on line 4 – Sumaia99 May 07 '16 at 16:16
  • Looks to me like the init.php you're including is not the one you have above. – Nathan Edwards May 07 '16 at 16:21
  • @NathanEdwards i actually had two **require_once** in init.php, one is: `require_once 'core/App.php';` and the second one is : `require_once 'core/Controller.php';` when i commented the line of the second one the value of echo in the App.php file was displayed correctly. – Sumaia99 May 07 '16 at 16:48
  • So either core/Controller.php doesn't exist or your apache server doesn't have the right permissions. I'm guessing the items in core are supposed to be part of your framework? – Nathan Edwards May 07 '16 at 16:58

0 Answers0