Blogger Information
Blog 26
fans 1
comment 0
visits 18869
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
类的自动加载
坏人也温柔de陈词滥调
Original
645 people have browsed it

index.php

实例

<?php
namespace Index;
use auto\say;
use auto\mycolor\color;
function my_autoload($name){
$name = str_replace('\\',DIRECTORY_SEPARATOR,$name);
require $name.'.class.php';
}
spl_autoload_register(__NAMESPACE__.'\\my_autoload');
$say = new say();
$say->hello();
$color = new color();

运行实例 »

点击 "运行实例" 按钮查看在线实例

class.php

实例

<?php
namespace auto;
class say{
public function hello(){
    echo "hello";

运行实例 »

点击 "运行实例" 按钮查看在线实例

auto.php

实例

<?php
namespace auto\mycolor;
class color{
public function test(){
    echo "blue";
}

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!