search
Homephp教程PHP源码简单的PHP框架实现antoload,viewEngine

1. [代码]index.php 入口文件    

<?php
function __autoload($class){
    include $class.&#39;.php&#39;;
}
$t = new tController();
$t->index();

2. [代码]Controller.php 核心控制器    

<?php
class Controller {
    function render($temple, $arr){
        extract($arr);
        ob_start();
        include $temple;
        $content = ob_get_contents();
        ob_end_clean();
        echo $content;
    }    
}

3. [代码]tController.php 普通控制器    

<?php
class tController extends Controller{
    function index(){
        $this->render(&#39;t.php&#39;, array(&#39;name&#39;=>&#39;aaaaaaaaaaa&#39;));
    }
}

4. [代码]t.php 视图文件    

<html>
        <header>
                <title></title>
        </header>
        <body>
                <?php  echo @$name; ?>
                <form method="post" action="">
                        用户名:<input name="username" type="text" value=""><br>
                        密码:   <input name="password" type="password"><br>
                        <input name="submit" type="submit" value="提交">
                </form>
        </body>
</html>

                   

                   

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function