Hướng dẫn get data from object php - lấy dữ liệu từ đối tượng php

Làm thế nào tôi có thể lấy user_nicename từ đối tượng này?

BP_User Object
(
    [data] => stdClass Object
        (
            [ID] => 1
            [user_login] => NICENICE
            [user_pass] => $P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5.
            [user_nicename] => NICENAME
            ...

Và tôi có thể tìm tài nguyên để tìm hiểu điều này ở đâu?

Hướng dẫn get data from object php - lấy dữ liệu từ đối tượng php

ajreal

46.2K10 Huy hiệu vàng86 Huy hiệu bạc119 Huy hiệu đồng10 gold badges86 silver badges119 bronze badges

Hỏi ngày 8 tháng 12 năm 2010 lúc 21:46Dec 8, 2010 at 21:46

2

$variable->data->user_nicename

nên làm việc.

Đã trả lời ngày 8 tháng 12 năm 2010 lúc 21:47Dec 8, 2010 at 21:47

Hướng dẫn get data from object php - lấy dữ liệu từ đối tượng php

PekkapekkaPekka

436K138 Huy hiệu vàng966 Huy hiệu bạc1081 Huy hiệu Đồng138 gold badges966 silver badges1081 bronze badges

2

Bạn cũng có thể in bằng cách khác

foreach($result->data as $newdata) //$result is variable that store raw data 
{
printf("name: %s, Pass: %s, nicename: %s 
", $newdata->user_login, $newdata->user_pass, $newdata->user_nicename); }

Kết quả sẽ được

name:NICENICE , Pass:$P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5., nicename:NICENAME

Đã trả lời ngày 23 tháng 1 năm 2015 lúc 11:07Jan 23, 2015 at 11:07

Shiv Singhshiv SinghShiv Singh

6.6483 Huy hiệu vàng39 Huy hiệu bạc47 Huy hiệu đồng3 gold badges39 silver badges47 bronze badges

19 năm trước

Ludvig dot ericson tại gmail dot com ¶object, use the new statement to instantiate a class:

class foo
{
    function 
do_foo()
    {
        echo 
"Doing foo."
    }
}
$bar = new foo;
$bar->do_foo();
?>

16 năm trước

Wyattstorch42 tại Outlook Dot Com ¶

8 năm trướcobject is converted to an object, it is not modified. If a value of any other type is converted to an object, a new instance of the stdClass built-in class is created. If the value was null, the new instance will be empty. An array converts to an object with properties named by keys and corresponding values. Note that in this case before PHP 7.2.0 numeric keys have been inaccessible unless iterated.

$obj = (object) array('1' => 'foo');
var_dump(isset($obj->{'1'})); // outputs 'bool(true)' as of PHP 7.2.0; 'bool(false)' previously
var_dump(key($obj)); // outputs 'string(1) "1"' as of PHP 7.2.0; 'int(1)' previously
?>

Đối với bất kỳ giá trị nào khác, một biến thành viên có tên scalar sẽ chứa giá trị.

$variable->data->user_nicename
0

hữu ích tại Stranger Dot Com ¶

10 năm trước

$variable->data->user_nicename
1

$variable->data->user_nicename
2

$variable->data->user_nicename
3

Anthony ¶

6 năm trước

$variable->data->user_nicename
4

$variable->data->user_nicename
5

$variable->data->user_nicename
6

$variable->data->user_nicename
3

Twitter/Matt2000 ¶

7 năm trước

$variable->data->user_nicename
8

$variable->data->user_nicename
9

$variable->data->user_nicename
3

Ashley Dambra ¶

8 năm trước

foreach($result->data as $newdata) //$result is variable that store raw data 
{
printf("name: %s, Pass: %s, nicename: %s 
", $newdata->user_login, $newdata->user_pass, $newdata->user_nicename); }
1

foreach($result->data as $newdata) //$result is variable that store raw data 
{
printf("name: %s, Pass: %s, nicename: %s 
", $newdata->user_login, $newdata->user_pass, $newdata->user_nicename); }
2

foreach($result->data as $newdata) //$result is variable that store raw data 
{
printf("name: %s, Pass: %s, nicename: %s 
", $newdata->user_login, $newdata->user_pass, $newdata->user_nicename); }
3

foreach($result->data as $newdata) //$result is variable that store raw data 
{
printf("name: %s, Pass: %s, nicename: %s 
", $newdata->user_login, $newdata->user_pass, $newdata->user_nicename); }
4

foreach($result->data as $newdata) //$result is variable that store raw data 
{
printf("name: %s, Pass: %s, nicename: %s 
", $newdata->user_login, $newdata->user_pass, $newdata->user_nicename); }
5

Nhà phát triển Dot Amankr tại Gmail Dot Com (Aman Kuma) ¶

6 năm trước

foreach($result->data as $newdata) //$result is variable that store raw data 
{
printf("name: %s, Pass: %s, nicename: %s 
", $newdata->user_login, $newdata->user_pass, $newdata->user_nicename); }
6

foreach($result->data as $newdata) //$result is variable that store raw data 
{
printf("name: %s, Pass: %s, nicename: %s 
", $newdata->user_login, $newdata->user_pass, $newdata->user_nicename); }
7

foreach($result->data as $newdata) //$result is variable that store raw data 
{
printf("name: %s, Pass: %s, nicename: %s 
", $newdata->user_login, $newdata->user_pass, $newdata->user_nicename); }
8

Twitter/Matt2000 ¶

7 năm trước

foreach($result->data as $newdata) //$result is variable that store raw data 
{
printf("name: %s, Pass: %s, nicename: %s 
", $newdata->user_login, $newdata->user_pass, $newdata->user_nicename); }
9

name:NICENICE , Pass:$P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5., nicename:NICENAME
0

$variable->data->user_nicename
3

Ashley Dambra ¶

8 năm trước

name:NICENICE , Pass:$P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5., nicename:NICENAME
2

name:NICENICE , Pass:$P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5., nicename:NICENAME
3

name:NICENICE , Pass:$P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5., nicename:NICENAME
4

name:NICENICE , Pass:$P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5., nicename:NICENAME
5

name:NICENICE , Pass:$P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5., nicename:NICENAME
6

$variable->data->user_nicename
3

Nhà phát triển Dot Amankr tại Gmail Dot Com (Aman Kuma) ¶

Mithras ¶

name:NICENICE , Pass:$P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5., nicename:NICENAME
8

14 năm trước

Brian Dot Weber1337 tại Gmail Dot Com ¶

name:NICENICE , Pass:$P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5., nicename:NICENAME
9

user_nicename0

user_nicename1

user_nicename2

$variable->data->user_nicename
3

5 năm trước

mailto dot aurelian tại gmail dot com ¶

user_nicename4

user_nicename5

user_nicename6

user_nicename7

user_nicename8

user_nicename9

$variable->data->user_nicename
3

12 năm trước

10 năm trước

new1

new2

new3

new4

new5

new6

cfreed tại Orange Dot Fr ¶

8 năm trước

new7

new8

new9

Nhà phát triển Dot Amankr tại Gmail Dot Com (Aman Kuma) ¶

Mithras ¶

class foo
{
    function 
do_foo()
    {
        echo 
"Doing foo."
    }
}
$bar = new foo;
$bar->do_foo();
?>
0

class foo
{
    function 
do_foo()
    {
        echo 
"Doing foo."
    }
}
$bar = new foo;
$bar->do_foo();
?>
1

class foo
{
    function 
do_foo()
    {
        echo 
"Doing foo."
    }
}
$bar = new foo;
$bar->do_foo();
?>
2

class foo
{
    function 
do_foo()
    {
        echo 
"Doing foo."
    }
}
$bar = new foo;
$bar->do_foo();
?>
3

class foo
{
    function 
do_foo()
    {
        echo 
"Doing foo."
    }
}
$bar = new foo;
$bar->do_foo();
?>
4

14 năm trước

Brian Dot Weber1337 tại Gmail Dot Com ¶

class foo
{
    function 
do_foo()
    {
        echo 
"Doing foo."
    }
}
$bar = new foo;
$bar->do_foo();
?>
5

class foo
{
    function 
do_foo()
    {
        echo 
"Doing foo."
    }
}
$bar = new foo;
$bar->do_foo();
?>
6

$variable->data->user_nicename
3

5 năm trước

8 năm trước

class foo
{
    function 
do_foo()
    {
        echo 
"Doing foo."
    }
}
$bar = new foo;
$bar->do_foo();
?>
8

class foo
{
    function 
do_foo()
    {
        echo 
"Doing foo."
    }
}
$bar = new foo;
$bar->do_foo();
?>
9

$variable->data->user_nicename
3

Nhà phát triển Dot Amankr tại Gmail Dot Com (Aman Kuma) ¶

Mithras ¶

null1

null2

null3

null4

null5

null6

null7

null8

$variable->data->user_nicename
3

14 năm trước

Brian Dot Weber1337 tại Gmail Dot Com ¶

$obj = (object) array('1' => 'foo');
var_dump(isset($obj->{'1'})); // outputs 'bool(true)' as of PHP 7.2.0; 'bool(false)' previously
var_dump(key($obj)); // outputs 'string(1) "1"' as of PHP 7.2.0; 'int(1)' previously
?>
0

5 năm trước

8 năm trước

$obj = (object) array('1' => 'foo');
var_dump(isset($obj->{'1'})); // outputs 'bool(true)' as of PHP 7.2.0; 'bool(false)' previously
var_dump(key($obj)); // outputs 'string(1) "1"' as of PHP 7.2.0; 'int(1)' previously
?>
1

$obj = (object) array('1' => 'foo');
var_dump(isset($obj->{'1'})); // outputs 'bool(true)' as of PHP 7.2.0; 'bool(false)' previously
var_dump(key($obj)); // outputs 'string(1) "1"' as of PHP 7.2.0; 'int(1)' previously
?>
2

$obj = (object) array('1' => 'foo');
var_dump(isset($obj->{'1'})); // outputs 'bool(true)' as of PHP 7.2.0; 'bool(false)' previously
var_dump(key($obj)); // outputs 'string(1) "1"' as of PHP 7.2.0; 'int(1)' previously
?>
3

$obj = (object) array('1' => 'foo');
var_dump(isset($obj->{'1'})); // outputs 'bool(true)' as of PHP 7.2.0; 'bool(false)' previously
var_dump(key($obj)); // outputs 'string(1) "1"' as of PHP 7.2.0; 'int(1)' previously
?>
4

$obj = (object) array('1' => 'foo');
var_dump(isset($obj->{'1'})); // outputs 'bool(true)' as of PHP 7.2.0; 'bool(false)' previously
var_dump(key($obj)); // outputs 'string(1) "1"' as of PHP 7.2.0; 'int(1)' previously
?>
5

Nhà phát triển Dot Amankr tại Gmail Dot Com (Aman Kuma) ¶

Mithras ¶

$obj = (object) array('1' => 'foo');
var_dump(isset($obj->{'1'})); // outputs 'bool(true)' as of PHP 7.2.0; 'bool(false)' previously
var_dump(key($obj)); // outputs 'string(1) "1"' as of PHP 7.2.0; 'int(1)' previously
?>
6

$obj = (object) array('1' => 'foo');
var_dump(isset($obj->{'1'})); // outputs 'bool(true)' as of PHP 7.2.0; 'bool(false)' previously
var_dump(key($obj)); // outputs 'string(1) "1"' as of PHP 7.2.0; 'int(1)' previously
?>
7

$obj = (object) array('1' => 'foo');
var_dump(isset($obj->{'1'})); // outputs 'bool(true)' as of PHP 7.2.0; 'bool(false)' previously
var_dump(key($obj)); // outputs 'string(1) "1"' as of PHP 7.2.0; 'int(1)' previously
?>
8

$obj = (object) array('1' => 'foo');
var_dump(isset($obj->{'1'})); // outputs 'bool(true)' as of PHP 7.2.0; 'bool(false)' previously
var_dump(key($obj)); // outputs 'string(1) "1"' as of PHP 7.2.0; 'int(1)' previously
?>
9

$variable->data->user_nicename
3

14 năm trước

mailto dot aurelian tại gmail dot com ¶

scalar1

scalar2

scalar3

$variable->data->user_nicename
3

12 năm trước

cfreed tại Orange Dot Fr ¶

scalar5

13 năm trước

Mithras ¶

scalar6

scalar7

scalar8

scalar9

14 năm trước

Brian Dot Weber1337 tại Gmail Dot Com ¶

$variable->data->user_nicename
00

$variable->data->user_nicename
01

$variable->data->user_nicename
02

$variable->data->user_nicename
03

$variable->data->user_nicename
3

5 năm trước

Brian Dot Weber1337 tại Gmail Dot Com ¶

$variable->data->user_nicename
05

$variable->data->user_nicename
06

$variable->data->user_nicename
3

5 năm trước

7 năm trước

$variable->data->user_nicename
08

$variable->data->user_nicename
09

$variable->data->user_nicename
10

$variable->data->user_nicename
11

$variable->data->user_nicename
12

$variable->data->user_nicename
13

Ashley Dambra ¶

8 năm trước

$variable->data->user_nicename
14

$variable->data->user_nicename
15

$variable->data->user_nicename
16

$variable->data->user_nicename
3