zoukankan      html  css  js  c++  java
  • php手册总结《类》

    手册页面:

    http://php.net/manual/zh/language.oop5.basic.php

    >> 类名

    类名可以是任何非 PHP 保留字的合法标签。一个合法类名以字母或下划线开头,后面跟着若干字母,数字或下划线。以正则表达式表示为:[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*

    注意:x7f-xff 代表汉字(故类名是可以用汉字表示的)

    https://segmentfault.com/q/1010000000726270?sort=created

    <?php
    class 名字
    {

    }
    echo 名字::class; //输出 => 名字
    exit;

     >> 复制

    当把一个对象已经创建的实例赋给一个新变量时,新变量会访问同一个实例,就和用该对象赋值一样。此行为和给函数传递入实例时一样。可以用克隆给一个已创建的对象建立一个新实例。

    <?php

    $instance = new SimpleClass();

    $assigned   =  $instance;
    $reference  =& $instance;

    $instance->var = '$assigned will have this value';

    $instance = null; // $instance and $reference become null

    var_dump($instance);
    var_dump($reference);
    var_dump($assigned);
    ?>

    以上例程会输出:

    NULL
    NULL
    object(SimpleClass)#1 (1) {
       ["var"]=>
         string(30) "$assigned will have this value"
    }
  • 相关阅读:
    取某个关键词以及之后的数据
    从SQL下载大量数据到Excel
    SQL 分页
    whereis linux文件搜索
    crontab Linux定时器工具
    Angular
    工具
    百度OAuth2.0登录
    JS事件学习 拖拽,鼠标键盘事件实例汇总
    信息栏滚动效果学习总结
  • 原文地址:https://www.cnblogs.com/Alight/p/6811213.html
Copyright © 2011-2022 走看看