第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

php 類(lèi)中$this問(wèn)題

php 類(lèi)中$this問(wèn)題

PHP
牧羊人nacy 2019-03-14 17:09:19
一個(gè)類(lèi)中的變量 public $id; public $group_id; public $parent_id; public $type; public $name; public $description; public $is_required; public $can_delete = '1'; public $field_order; public $option_order; public $order_by; public $is_default_option; protected $default_visibility; protected $allow_custom_visibility; public $do_autolink; public $type_obj = null; public $data; protected $member_types; public function __construct( $id = null, $user_id = null, $get_data = true ) { if ( ! empty( $id ) ) { $this->populate( $id, $user_id, $get_data ); // Initialise the type obj to prevent fatals when creating new profile fields. } else { $this->type_obj = bp_xprofile_create_field_type( 'textbox' ); $this->type_obj->field_obj = $this; } } 其中一段 public function fill_data( $args ) { if ( is_object( $args ) ) { $args = (array) $args; } $int_fields = array( 'id', 'is_required', 'group_id', 'parent_id', 'is_default_option', 'field_order', 'option_order', 'can_delete' ); foreach ( $args as $k => $v ) { if ( 'name' === $k || 'description' === $k ) { $v = stripslashes( $v ); } // Cast numeric strings as integers. if ( true === in_array( $k, $int_fields ) ) { $v = (int) $v; } $this->{$k} = $v; } // Create the field type and store a reference back to this object. $this->type_obj = bp_xprofile_create_field_type( $this->type ); $this->type_obj->field_obj = $this; } bp_xprofile_create_field_type是一個(gè)公共函數(shù),返回?cái)?shù)據(jù)是 {"name":"單選按鈕","category":"多項(xiàng)資料","accepts_null_value":false,"supports_options":true,"supports_multiple_defaults":false,"supports_richtext":false,"field_obj":null} 請(qǐng)問(wèn)函數(shù)fill_data 中$this到底是什么意思呢 $this代表剛剛生成的$this->{$k}數(shù)組嗎?
查看完整描述

2 回答

?
三國(guó)紛爭(zhēng)

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超7個(gè)贊

$this是一個(gè)指向調(diào)用方的引用,既然是引用,那么就跟實(shí)例有一樣的效果,比如訪(fǎng)問(wèn)屬性,方法,或者給屬性賦值等。但$this并不是出現(xiàn)在某個(gè)類(lèi)里面就代表該類(lèi)的實(shí)例,比如說(shuō)在繼承的情況下,$this可能指向的是子類(lèi)實(shí)例。

查看完整回答
反對(duì) 回復(fù) 2019-03-18
?
慕桂英546537

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超10個(gè)贊

當(dāng)前對(duì)象實(shí)例

查看完整回答
反對(duì) 回復(fù) 2019-03-18
  • 2 回答
  • 0 關(guān)注
  • 607 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)