1

I am trying to understand the ArrayObject::STD_PROP_LIST const, As it defined at the manual:

Properties of the object have their normal functionality when accessed as list (var_dump, foreach, etc.).

I write this code:

$array = array(5,7,9,3,6,5,4);
$arrayObj = new ArrayObject($array);
var_dump($arrayObj);
$arrayObj2 = new ArrayObject($arrayObj->getArrayCopy(), ArrayObject::STD_PROP_LIST);
var_dump($arrayObj2);

At the first var_dump we can see the array elements but at the second var_dump you can't see them, I also tested foreach and the foreach loop work for both arrayObj object and arrayObj2 object.

If can some one please explain to me what is normal functionality and why the second var_dump elements is not presented, Thank you all and have a nice day.

3
  • your code works for me. both var_dumps look the same: phpfiddle.org/main/code/7x3-dkd Commented Sep 13, 2012 at 11:13
  • i can reproduce it, PHP 5.3.3-1ubuntu9.10. print_r and count() works but not var_dump Commented Sep 13, 2012 at 11:18
  • Thank you all for your answers, I am using PHP Version 5.4.3, but lets say its a bug, what doe's the normal functionality as mentioned at the manual definition for STD_PROP_LIST, If some one can explain it to me please. Commented Sep 13, 2012 at 11:45

1 Answer 1

2

Am sure you are using anything <= PHP Version 5.3.8 .. It a bug have also detected you would get the following

    object(ArrayObject)#1 (7) { [0]=> int(5) [1]=> int(7) [2]=> int(9) [3]=> int(3) [4]=> int(6) [5]=> int(5) [6]=> int(4) } 
    object(ArrayObject)#2 (0) { }

If you run on PHP 5.3.10 you would get the following

    object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(7) { [0]=> int(5) [1]=> int(7) [2]=> int(9) [3]=> int(3) [4]=> int(6) [5]=> int(5) [6]=> int(4) } } 
    object(ArrayObject)#2 (1) { ["storage":"ArrayObject":private]=> array(7) { [0]=> int(5) [1]=> int(7) [2]=> int(9) [3]=> int(3) [4]=> int(6) [5]=> int(5) [6]=> int(4) } }

I think you should upgrade your version of PHP

Sign up to request clarification or add additional context in comments.

1 Comment

the behaviour of flags should only affects the way properties are readable/writable so that's probably a bug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.