search

<span> 1</span> <span>php
</span><span> 2</span> <span>/*</span><span>*
</span><span> 3</span> <span> * @desc test reflectionclass
</span><span> 4</span> <span> * @author songweiqing
</span><span> 5</span> <span> * @create_time 2015-01-7
</span><span> 6</span> <span> *
</span><span> 7</span>  <span>*/</span>
<span> 8</span>  <span>class</span><span> Test{
</span><span> 9</span>     <span>public</span> <span>$attr1</span> = 'attr1'<span>;
</span><span>10</span>     <span>protected</span> <span>$attr2</span> = 'attr2'<span>;
</span><span>11</span>     <span>private</span> <span>$attr3</span> = 'attr3'<span>;
</span><span>12</span>     <span>const</span> ATTR4 = 'I AM THE ATTRIBUTE 4'<span>;
</span><span>13</span>     <span>public</span> <span>static</span> <span>$attr5</span> = 'attr5'<span>;
</span><span>14</span>     
<span>15</span>     <span>public</span> <span>function</span><span> __construct(){
</span><span>16</span>         
<span>17</span>         self::<span>$attr5</span> = 'I love you baby'<span>;
</span><span>18</span> <span>    }
</span><span>19</span>     <span>public</span> <span>function</span><span> getAttr1(){
</span><span>20</span>         
<span>21</span>         <span>echo</span> <span>$this</span>-><span>attr1;
</span><span>22</span> <span>    }
</span><span>23</span>     <span>//</span><span>获取属性2</span>
<span>24</span>     <span>protected</span> <span>function</span><span> getAttr2(){
</span><span>25</span>         
<span>26</span>         <span>echo</span> <span>$this</span>-><span>attr2;
</span><span>27</span> <span>    } 
</span><span>28</span>     <span>/*</span><span>*
</span><span>29</span> <span>     * @desc 获取属性3
</span><span>30</span> <span>     * @return string 
</span><span>31</span>      <span>*/</span>
<span>32</span>     <span>private</span> <span>function</span><span> getAttr3(){
</span><span>33</span>         <span>echo</span> <span>$this</span>-><span>attr3;
</span><span>34</span> <span>    }
</span><span>35</span>     
<span>36</span>     <span>public</span> <span>static</span> <span>function</span><span> getAttr5(){
</span><span>37</span>         <span>echo</span> self::<span>$attr5</span><span>;
</span><span>38</span> <span>    }
</span><span>39</span> <span>}
</span><span>40</span> 
<span>41</span> <span>$reflection</span> = <span>new</span> ReflectionClass('Test'<span>);
</span><span>42</span> <span>//</span><span>var_dump($reflection->getName());//获取类名getName();
</span><span>43</span> <span>//var_dump($reflection->getConstant("ATTR4"));//获取指定的常量名
</span><span>44</span> <span>//var_dump($reflection->getConstants());//获取一组常量名
</span><span>45</span> <span>//var_dump($reflection->getConstructor());//获取构造函数,没有构造函数返回null
</span><span>46</span> <span>//var_dump($reflection->getDefaultProperties());//获取默认属性,常量属性不包括
</span><span>47</span> <span>//var_dump($reflection->getDocComment());//获取针对该类的注释,对于类中法中的注释,忽略,没有返回false
</span><span>48</span> <span>//var_dump($reflection->getEndLine());//获取类中最后一行行数
</span><span>49</span> <span>//var_dump($reflection->getFileName());//获取定义类的类名
</span><span>50</span> <span>//var_dump($reflection->getMethods());//获取所有类中的方法
</span><span>51</span> <span>//var_dump($reflection->getProperties());//获取所有属性,不包含常量属性
</span><span>52</span> <span>//$instance = $reflection->newInstanceArgs();//实例化反射的该类
</span><span>53</span> <span>//$instance = $reflection->newInstance('Test');实例化指定的类</span>
View Code

The above has introduced PHP ReflectionClass, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

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
华为GT3 Pro和GT4的差异是什么?华为GT3 Pro和GT4的差异是什么?Dec 29, 2023 pm 02:27 PM

许多用户在选择智能手表的时候都会选择的华为的品牌,其中华为GT3pro和GT4都是非常热门的选择,不少用户都很好奇华为GT3pro和GT4有什么区别,下面就就给大家介绍一下二者。华为GT3pro和GT4有什么区别一、外观GT4:46mm和41mm,材质是玻璃表镜+不锈钢机身+高分纤维后壳。GT3pro:46.6mm和42.9mm,材质是蓝宝石玻璃表镜+钛金属机身/陶瓷机身+陶瓷后壳二、健康GT4:采用最新的华为Truseen5.5+算法,结果会更加的精准。GT3pro:多了ECG心电图和血管及安

dump文件是什么文件dump文件是什么文件Jan 12, 2024 pm 04:58 PM

dump文件通常是指一种二进制文件,也被称为转储文件或核心转储文件。这种文件是计算机系统在遇到严重错误或异常情况时生成的,用于存储系统或应用程序的状态、堆栈、寄存器、内存映像、日志等信息。

修复:截图工具在 Windows 11 中不起作用修复:截图工具在 Windows 11 中不起作用Aug 24, 2023 am 09:48 AM

为什么截图工具在Windows11上不起作用了解问题的根本原因有助于找到正确的解决方案。以下是截图工具可能无法正常工作的主要原因:对焦助手已打开:这可以防止截图工具打开。应用程序损坏:如果截图工具在启动时崩溃,则可能已损坏。过时的图形驱动程序:不兼容的驱动程序可能会干扰截图工具。来自其他应用程序的干扰:其他正在运行的应用程序可能与截图工具冲突。证书已过期:升级过程中的错误可能会导致此issu简单的解决方案这些适合大多数用户,不需要任何特殊的技术知识。1.更新窗口和Microsoft应用商店应用程

怎样剖析CLDAP协议 Reflection DDoS怎样剖析CLDAP协议 Reflection DDoSMay 22, 2023 pm 01:13 PM

前言2018年上半年,得益于Memcache近5万的反射放大倍数,DDoS的峰值流量已经达到了一个前所未有的新高度—1.7Tbps,这也使得MemcacheReDDoS成为目前DDoS的中坚力量。而与MemcacheReDDoS相比,2016年Akamai曝光的CLDAPReDDoS虽然没有前者极高的效率,但是其56~70倍的放大倍数在DDoS家族中也依然是一名佼佼者,因此也应引起关注。一、CLDAP协议缺陷轻量目录访问协议(LDAP)被定义在RFC2251(LDAPv3)中,由于LDAP是以T

如何修复无法连接到iPhone上的App Store错误如何修复无法连接到iPhone上的App Store错误Jul 29, 2023 am 08:22 AM

第1部分:初始故障排除步骤检查苹果的系统状态:在深入研究复杂的解决方案之前,让我们从基础知识开始。问题可能不在于您的设备;苹果的服务器可能会关闭。访问Apple的系统状态页面,查看AppStore是否正常工作。如果有问题,您所能做的就是等待Apple修复它。检查您的互联网连接:确保您拥有稳定的互联网连接,因为“无法连接到AppStore”问题有时可归因于连接不良。尝试在Wi-Fi和移动数据之间切换或重置网络设置(“常规”>“重置”>“重置网络设置”>设置)。更新您的iOS版本:

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code<form name="myform"

在 Windows 11 上修复音频服务无响应问题的 18 种方法在 Windows 11 上修复音频服务无响应问题的 18 种方法Jun 05, 2023 pm 10:23 PM

音频输出和输入需要特定的驱动程序和服务才能在Windows11上按预期工作。这些有时最终会在后台遇到错误,从而导致音频问题,如无音频输出、缺少音频设备、音频失真等。如何修复在Windows11上没有响应的音频服务我们建议您从下面提到的修复开始,并逐步完成列表,直到您设法解决您的问题。由于Windows11上的多种原因,音频服务可能无法响应。此列表将帮助您验证和修复阻止音频服务在Windows11上响应的大多数问题。请按照以下相关部分帮助您完成该过程。方法一:重启音频服务您可能会遇

PHP中var关键字的作用和示例PHP中var关键字的作用和示例Jun 28, 2023 pm 08:58 PM

PHP中var关键字的作用和示例在PHP中,var关键字用于声明一个变量。以前的PHP版本中,使用var关键字是声明成员变量的惯用方式,现在已经不再推荐使用。然而,在某些情况下,var关键字依然会被使用。var关键字主要用于声明一个局部变量,并且会自动将该变量标记为局部作用域。这意味着该变量仅在当前的代码块中可见,并且不能在其他函数或代码块中访问。使用var

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft