<?php

加载类
//include("./Ren.class.php");
//include "./Ren.class.php";
include_once("./Ren.class.php");
include_once("./Ren.class.php");
$f = new Ren();
$f->test();

require("./Ren.class.php");
require_once("./Ren.class.php");
require_once "./Ren.class.php";
$f = new Ren();
$f->test();

自动加载类
//1.所有类文件名和类名要保持一致
//2.所有类文件放在同一文件下
//3.所有类文件命名规则一致
function __autoload($cname){
    require_once("./$cname.class.php");    
}
$t = new test();
$t->ceshi().'<br>';
$s = new Ren();
$s->test();

两种魔术方法
 class Ren{
    public $name;
    public function say(){
        echo "输出对象方法";    
    }
    //输出对象的方法
    public function __tostring(){
        echo "另一种输出方法";    //echo $s->__tostring();
        return "另一种输出方法";//echo $s;
    }
    //克隆对象的方法
    public function __clone(){
        $this->name = "Riven";//$this代表复本(克隆的对象)
    }
}
$s = new Ren();
//echo $s->__tostring();//输出字符串
//$s->say();

$s->name = "小V";
var_dump($s);

$s1 = clone $s;
var_dump($s1);
?>

最新文章

  1. fopen函数和fread函数、fwrite函数
  2. C# Async, Await and using statements
  3. spring IOC装配Bean(注解方式)
  4. axis 理解
  5. 快手4.0 (KSCAD)
  6. BZOJ2159 : Crash 的文明世界
  7. 最近发现docker感觉不错
  8. 选择Nodejs的N个理由
  9. Restful风格的简单实现办法
  10. 本地代码git到github上
  11. js 实现 input type=&quot;file&quot; 文件上传示例代码
  12. 编程从入门到提高,然后放弃再跑路(Java)
  13. bzoj 2510 弱题 矩阵乘
  14. Linux网络技术管理及进程管理(week2_day4)--技术流ken
  15. zabbix监控nginx连接数量
  16. ORACLE 计算时间相减间隔
  17. http://www.bugku.com:Bugku——变量1(http://120.24.86.145:8004/index1.php)
  18. php+C#.net混合开发
  19. ul li剧中对齐
  20. Json.Net 反序列化成匿名对象

热门文章

  1. 解决忘记mysql中的root用户密码问题
  2. VSCode and NoteBook for JavaScript | NodeJS
  3. 用Python计算幂的两种方法,非递归和递归法
  4. kafka为什么这么优秀!
  5. js jquery css 选择器总结
  6. 纪中2018暑假培训day3提高a组改题记录(混有部分b组)
  7. A1125. Chain the Ropes
  8. jQuery、layer实现弹出层的打开、关闭功能实例详解
  9. 回流(reflow)与重绘(repaint)
  10. 91 Testing MySQL学习总结