I am getting the following error:
Warning: require_once(C:\xampp\htdocs\mvc\public\views\home\init.php): failed to open stream: No such file or directory in C:\xampp\htdocs\mvc\public\index.php on line 3
Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs\mvc\public\views\home\init.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\mvc\public\index.php on line 3
In Index.php, my code is
<?php
require_once __DIR__ . '\views\home\init.php';
$app= new app;
?>
In init.php, my code is
<?php require_once __DIR__ . '\core\app.php';
require_once __DIR__ . '\core\controller.php';
In controller.php:
<?php
class controller
{
}
?>
In app.php
<?php
class app
{
public function _construct()
{
echo 'now what';
}
}
?>
My folder paths are:
htdocs\mvc\app\views\home\init.php
htdocs\mvc\app\core\app.php & controller.php
htdocs\mvc\public\index.php
Anybody please help? i have tried require_once (_DIR . ""); as well but not working.
index.php
is located atpublic/
folder, while your required fileviews/home/init.php
is located atapp/
folder. So, tryrequire '../app/views/home/init.php';
If it doesn't work, you can tryrealpath (__FILE__.'../app');
to get yourapp/
folder's realpath name. – Chu Ya'an Xiaonan../../views/home/init.php
, I've forgot another..
– Chu Ya'an Xiaonan