日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

php中mysql和mysqli_php mysqli中-和::有什么区别?

發(fā)布時(shí)間:2023/12/10 数据库 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php中mysql和mysqli_php mysqli中-和::有什么区别? 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

->用來(lái)訪問(wèn)實(shí)例的成員,一般左面是一個(gè)類實(shí)例(或者$this), 右面是一個(gè)函數(shù)或者屬性. 箭頭也可以通過(guò)類實(shí)例來(lái)訪問(wèn)靜態(tài)函數(shù).

::用來(lái)訪問(wèn)靜態(tài)成員、常量,訪問(wèn)父類中的成員. 一般左面是一個(gè)類名,或self、parent、static關(guān)鍵字, 右面是一個(gè)靜態(tài)函數(shù)、靜態(tài)屬性、常量.<?php

// 費(fèi)了我好大功夫, 把這些都總結(jié)到一個(gè)例子里面了

// PHP5.3 PHP5.4 PHP5.5 測(cè)試通過(guò)

class A

{

//類常量

const constValue = "constValue\n";

//類屬性

public $property = "properties\n";

//靜態(tài)屬性

static public $staticProperty = "staticProperty\n";

//普通函數(shù)

public function func()

{

}

//靜態(tài)函數(shù)

static public function staticFunc()

{

}

}

$xxoo = new A;

//訪問(wèn)實(shí)例的屬性

print $xxoo->property;

//訪問(wèn)實(shí)例的函數(shù)

print $xxoo->func();

//也可以借助實(shí)例來(lái)訪問(wèn)靜態(tài)成員

//訪問(wèn)函數(shù)要用箭頭,屬性要用雙冒號(hào)

print $xxoo->staticFunc();

print $xxoo::$staticProperty;

//如果不借助實(shí)例,那就直接用類名加雙冒號(hào)

print A::staticFunc();

print A::constValue;

//靜態(tài)屬性要加美元符號(hào)

print A::$staticProperty;

//繼承類A

class B extends A

{

//覆蓋父類的屬性

public $property = "covered-properties\n";

//覆蓋父類的靜態(tài)屬性

static public $staitcProperty = "covered-staitcProperties\n";

//覆蓋父類的函數(shù)

public function func()

{

//訪問(wèn)自己的屬性

print $this->property;

//訪問(wèn)從父類繼承來(lái)的靜態(tài)屬性

print self::$staticProperty;

//訪問(wèn)自己的(靜態(tài))函數(shù)

print $this->staticFunc();

//強(qiáng)制指定訪問(wèn)父類(而不是自己)的函數(shù)

print parent::func();

}

//覆蓋父類的靜態(tài)函數(shù)

static public function staticFunc()

{

//因?yàn)闆](méi)有$this, 所以用self訪問(wèn)自己的靜態(tài)屬性

print self::$staitcProperty;

}

}

//運(yùn)行一下上面的例子

$xxoo = new B;

$xxoo->func();

B::staticFunc();

總結(jié):

箭頭:通過(guò)實(shí)例訪問(wèn)屬性、(靜態(tài))函數(shù)

雙冒號(hào):通過(guò)類名或self、parent、static關(guān)鍵字,訪問(wèn)常量、靜態(tài)屬性、靜態(tài)函數(shù)

http://php.net/manual/zh/language.oop...

PHP5.3新增后期靜態(tài)綁定功能,和雙冒號(hào)以及static關(guān)鍵字有關(guān),這個(gè)我正在學(xué)習(xí)中.....

總結(jié)

以上是生活随笔為你收集整理的php中mysql和mysqli_php mysqli中-和::有什么区别?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。