我从基本的php有一个非常简单的问题。
在moodle我用php做了这个
print_r($USER)
获取$ USER变量传递的所有信息(下面的代码片段,我认为它是数组)
stdClass Object ( [id] => 4 [auth] => email [confirmed] => 1 [policyagreed] => 0 [deleted] => 0 [suspended] => 0 [mnethostid] => 1 [username] => testowy [idnumber] => [firstname] => Firstname [lastname] => Testowy [email] => aaa@aaa.pl [emailstop] => 0 [icq] => [skype] => [yahoo] => [aim] => [msn] => [phone1] => [phone2] => [institution] => [department] => [address] => [city] => AAABBB [country] => PL [lang] => [calendartype] => gregorian [theme] => [timezone] => 99 [firstaccess] => 1392147531 [lastaccess] => 1392927159 [lastlogin] => 1392841140 >
我想获得名为[firstname]和field [lastname]的字段并将其置于联系表单中。有人可以写信给我怎么做?
感谢您的帮助,最好的问候
答案 0 :(得分:2)
stdClass Object
是object
,不是数组。在PHP中,为了从对象获取值,我们使用->
,在数组中我们使用[]
。
只是做:
$USER->firstname
和
$USER->lastname