this就是指向当前对象实例的指针,不指向任何其他对象或类

如$this->fun1();

self:指向类本身,也就是self是不指向任何已经实例化的对象 ,self使用来指向类中的静态属性或者方法

self::$staticProperty

self::staticMothed;

parent: 指向父类的指针,一般我们使用parent来调用父类的构造函数或父类中的静态属性或静态方法

self与parent要结合::(域运算符号)

parent::$staticProperty

parent::Mothed;

--------注意$出现的位置,与this不同

$this绑定---这一点与C#不同

当一个对象调用一个它对应类的方法时,该方法执行之前先完成一个绑定,即是用

$this绑定到调用此方法的对象

即类的成员函数访问类中的属性或调用其他成员函数时,必须在前面加$this->

(这样才能在方法内对这个对象的属性进行操纵),如果没加的话,理解为方法内部的一个局部变量

php中的this,self,parent的更多相关文章

  1. android中出现Error retrieving parent for item: No resource found that matches the Theme.AppCompat.Light

    styles.xml中<style name="AppBaseTheme" parent="Theme.AppCompat.Light">提示如下错 ...

  2. Spring中 bean定义的parent属性机制的实现分析

    在XML中配置bean元素的时候,我们常常要用到parent属性,这个用起来很方便就可以让一个bean获得parent的所有属性 在spring中,这种机制是如何实现的?     对于这种情况 tra ...

  3. PHP面向对象中 static:: 与 self:: parent:: $this-> 的区别

    很多好几年工作经验的PHP工程师,对PHP面向对象中 static:: .self::.parent::.$this->  的定义和使用都不清晰,特做详细梳理: static:: 可以访问全局作 ...

  4. 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法

    "window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...

  5. 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法与区别(跳出iframe方法)

    "window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...

  6. 关于js中window.location.href,location.href,parent.location.href,top.location.href的使用方法

    关于js中"window.location.href"."location.href"."parent.location.href".&qu ...

  7. 关于js中window.location.href,location.href,parent.location.href,top.location.href用法

    "window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...

  8. 关于VUE调用父实例($parent) 根实例 中的数据和方法

    this.$parent或者 this.$root 在子组件中判断this.$parent获取的实例是不是父组件的实例 在子组件中console.log(this.$parent)  在父组件中con ...

  9. spring中bean的配置详解--定义parent

    在工作中碰到了好多的配置文件,具体来说是spring 中bean配置的parent的配置,搞的我一头雾水,仔细看一下spring中有关bean的配置,剖析一下,具体什么含义! 一.Spring IoC ...

  10. maven项目pom.xml中parent标签的使用(转)

    原文地址:https://blog.csdn.net/qq_41254677/article/details/81011681 使用maven是为了更好的帮项目管理包依赖,maven的核心就是pom. ...

随机推荐

  1. idea 新建一个java项目并运行

    这个只能算是个笔记,参考:参考文档 打开Idea,选择create new project,如图 或选择File ——> New——>Project... 出现以下界面,选中Java,然后 ...

  2. bootstrap 4 pull-right无效

    /********************************************************************** * bootstrap 4 pull-right无效 * ...

  3. PTA——模拟除法

    PTA 7-42 整除光棍 #include <stdio.h> int main() { ];//创建存表 ,count=; int n; ; scanf("%d", ...

  4. 为移动端而设计的bootstrap的使用

    一.下载 --bs ---css ----bootstrap.css ----bootstrap.min.css ---fonts ---js ----bootstrap.js ----jquery. ...

  5. 斐波那契数列的生成 %1e8 后的结果

    方法一  用数组开,一般开到1e7,1e8 左右的数组就是极限了   对时间也是挑战 #include<bits/stdc++.h> using namespace std; ; int ...

  6. LeetCode - Two Sum IV - Input is a BST

    Given a Binary Search Tree and a target number, return true if there exist two elements in the BST s ...

  7. SpringMvc和Mybatis整合总结

    1.先配置mybatis,测试读取数据库 2.自己测试数据 3.配置spring和springmvc, PS:配置web.xml,这样就不用getBean了 4.配置Controller 5.前后台交 ...

  8. JS从数组中随机取出几个数组元素的方法

    原文链接:http://caibaojian.com/js-get-random-elements-from-array.html js如何从一个数组中随机取出一个元素或者几个元素. 假如数组为· v ...

  9. 04C++const增强、枚举的增强

    #include <iostream> int main(void) { //const定义常量--->const意味着只读 const int a; int const b; // ...

  10. Oracle12C版本安装步骤

    一.下载路径 http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html file1,file ...