gpt4 book ai didi

php 类型转换和数组引用

转载 作者:行者123 更新时间:2023-12-04 16:45:23 25 4
gpt4 key购买 nike

我在 PHP OOPS 代码中遇到问题。

我的代码是:

class Settings
{

private $client_addr = array(
'ClientID' => array('maxlength'=>'10','IsNull'=>'n'),
'ClientAddressType' => array('maxlength'=>'12','IsNull'=>'y'),
'ClientAddressLine1' => array('maxlength'=>'30','IsNull'=>'y'),
'ClientAddressLine2' => array('maxlength'=>'30','IsNull'=>'y'),
'ClientCounty' => array('maxlength'=>'30','IsNull'=>'y'),
'ClientCity' => array('maxlength'=>'30','IsNull'=>'y'),
'ClientState' => array('maxlength'=>'2','IsNull'=>'y'),
'ClientZip' => array('maxlength'=>'9','IsNull'=>'y'),
);
private $client_general = array(
'PayerID' => array('maxlength'=>'64','IsNull'=>'n'),
'ProviderID' => array('maxlength'=>'50','IsNull'=>'n'),
'ClientID' => array('maxlength'=>'10','IsNull'=>'n'),
'ClientFirstName' => array('maxlength'=>'30','IsNull'=>'n'),
'ClientMiddleInitial' => array('maxlength'=>'1','IsNull'=>'y'),
'ClientLastName' => array('maxlength'=>'30','IsNull'=>'n'),
);

function getSelectedArrayData($setlected_arr)
{
$setlected_arr = '$this->'."$setlected_arr";
print_r($setlected_arr); //it prints a string '$this->client_general'
print_r($this->client_general);//it prints $client_general array data
}

}

$settings = new Settings();

$settings->getSelectedArrayData('client_general');

我的问题是:

当我打印 print_r($this->client_general); 时,它会打印 $client_general 数组,这是可以的。

Array
(
[PayerID] => Array
(
[maxlength] => 64
[IsNull] => n
)

[ProviderID] => Array
(
[maxlength] => 50
[IsNull] => n
)

[ClientID] => Array
(
[maxlength] => 10
[IsNull] => n
)

[ClientFirstName] => Array
(
[maxlength] => 30
[IsNull] => n
)

[ClientMiddleInitial] => Array
(
[maxlength] => 1
[IsNull] => y
)

[ClientLastName] => Array
(
[maxlength] => 30
[IsNull] => n
)

)

当我打印 print_r($setlected_arr); 时,它被打印了

$this->client_general

我想它也应该指向 $client_general 数组。

我该怎么做?

最佳答案

print_r($this->$setlected_arr);

关于php 类型转换和数组引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55396060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com