How to create a DOMDocument object variable in the class? What should I do?

Source: Internet
Author: User
How to create a DOMDocument object variable in the class? & Lt ;? PhpclassXXX {private $ _ musicnewDOMDocument ();} in this way, an error is reported, but $ _ musicnewDOMDocument () is not directly returned in this case in the class, how can I create such an object variable in a class? ------ Solution --------------- How to create the DOMDocument object variable in the class?
Class XXX
{
Private $ _ music = new DOMDocument ();
}

In this way, an error is reported,
However, this is not the case in the class.
$ _ Music = new DOMDocument ();

No error is reported. how can I create such an object variable in the class?

------ Solution --------------------
A syntax error occurs. variables from the manual attributes can be initialized, but the initialization value must be a constant. the constant here means that the php script is a constant during compilation, instead of the constant calculated in the running phase after the compilation phase.
Generally, values are assigned to the _ construct () constructor, while values are declared outside the construct () constructor.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.