Update index.php

This commit is contained in:
Namhyeon Go 2017-12-25 19:19:42 +09:00 committed by GitHub
parent fc1ef5ea43
commit 69a887767a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,10 +3,11 @@
* VerySimplePHPFramework * VerySimplePHPFramework
* http://github.com/gnh1201/verysimplephpframework * http://github.com/gnh1201/verysimplephpframework
* Go Namhyeon <gnh1201@gmail.com> * Go Namhyeon <gnh1201@gmail.com>
* Date: 2017-12-23 * Date: 2017-12-18
*/ */
define("_DEF_VSPF_", true); define("_DEF_VSPF_", true);
ini_set("max_execution_time", 0);
// including vendor autoloader // including vendor autoloader
include_once('./vendor/autoload.php'); include_once('./vendor/autoload.php');
@ -36,12 +37,21 @@ if(empty($route)) {
} }
// view render // view render
function renderView($name) { function renderView($name, $data=array()) {
if(count($data) > 0) {
extract($data);
}
$viewfile = './view/' . $name . '.php'; $viewfile = './view/' . $name . '.php';
if(file_exists($viewfile)) { if(file_exists($viewfile)) {
include($viewfile); include('./view/' . $name . '.php');
} }
} }
// including route file // including route file
include('./route/' . $route . '.php'); $route_file_name = './route/' . $route . '.php';
if(file_exists($route_file_name)) {
include('./route/' . $route . '.php');
} else {
echo "404 Not Found";
}