1

one can init an empty array in class in php like this:

class Foo
{
    protected $bar = [];
}

but how can I do this in extension developed with c?

notice that the $bar property is not initialized in constructor.

I've already tried the zend_declare_property function, but I get this error:

Fatal error: Internal zval's can't be arrays, objects or resources in Unknown on line 0

PS: [] is the shortcut for array() in php5.4, and my question is about writing php extension (with c), not about php itself. I know my english is not good enough but if something I've written is hard to understand, please let me know.

1
  • 1
    declaring a empty array like that only works in php 5.4 Commented Sep 5, 2012 at 10:27

1 Answer 1

0

Maybe you want something like this..

protected $bar = array();
Sign up to request clarification or add additional context in comments.

Comments

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.