Home Backend Development PHP Tutorial 怎样在类里面创建DOMDocument对象变量?该如何处理

怎样在类里面创建DOMDocument对象变量?该如何处理

Jun 13, 2016 pm 01:42 PM
domdocument music new

怎样在类里面创建DOMDocument对象变量?
class XXX
{
private $_music = new DOMDocument();
}

这样就报错了,
然而不在类里面直接这样的话
$_music = new DOMDocument();

就不报错,请问在类里面要怎样才能创建这样的对象变量?

------解决方案--------------------
语法错误而已,摘自手册 属性中的变量可以初始化,但是初始化的值必须是常数,这里的常数是指php脚本在编译阶段时就为常数,而不是在编译阶段之后在运行阶段运算出的常数。
一般都是放到 __construct()构造函数里赋值,而外面只是声明。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

iOS17 apple music dynamic cover does not move? 9 ways to fix it! iOS17 apple music dynamic cover does not move? 9 ways to fix it! Feb 05, 2024 am 11:15 AM

With the latest iOS17 upgrade, Apple Music has gained the animated cover art feature, adding moving elements to cover images. This feature makes the Apple Music experience more intuitive. But what if AppleMusic album animated cover art doesn't work on your iPhone? For all this time, I have elaborated on some simple yet effective workarounds to fix this glitch. 1. Update iOS AppleMusic’s animated cover art feature is exclusive to iOS17 or later, so make sure your device is updated to the latest iOS version. You can update your device by going to Settings → General → Software Update → Check for available updates and tap Update now. also,

FiiO CP13 cassette player launches with transparent retro look FiiO CP13 cassette player launches with transparent retro look Jun 16, 2024 am 09:52 AM

TheFiiOCP13cassetteplayerwasannouncedinJanuary.Now,FiiOisexpandingitsportfoliowithtwonewmodels-onewitharedfrontandonewithatransparentfront.Thelatternotonlyperfectlymatchestheretrocharmoftheangulardesign,butalso

How to change playlist pictures on Apple Music How to change playlist pictures on Apple Music May 10, 2023 pm 06:31 PM

How to Change Playlist Picture on Apple Music Changing your playlist picture allows you to customize it for easier recognition on iPhone, iPad, and Android devices. To change the playlist picture on AppleMusic, do the following: Launch AppleMusic on your iPhone or iPad. After the AppleMusic app opens, click Playlist in the menu. Next, click on the playlist where you want to change the images. With the playlist open, tap the options (three dots) icon in the upper right corner. In the menu, click the Edit button at the top of the menu. When you view a playlist image, you'll see a camera icon in the center of the image - click on it. A

DOMDocument in PHP8.0 DOMDocument in PHP8.0 May 14, 2023 am 08:18 AM

With the release of PHP 8.0, DOMDocument, PHP's built-in XML parsing library, has also undergone new changes and enhancements. The importance of DOMDocument in PHP is self-evident, especially in processing XML documents. It is very powerful and very simple to use. This article will introduce the new features and applications of DOMDocument in PHP8.0. 1. Overview of DOMDocumentDOM (DocumentObjectModel)

TikTok launches new feature to add songs to Apple Music, Spotify and Amazon Music libraries TikTok launches new feature to add songs to Apple Music, Spotify and Amazon Music libraries Nov 15, 2023 am 09:53 AM

According to news from this site on November 15, TikTok today launched a new "Add to Music App" function, which supports adding your favorite music to Apple Music, Spotify and Amazon Music. Users can find the "Add Song" button next to the video BGM name at the bottom of TikTok's "Recommended" page, and click to save songs on TikTok to the music library of the music streaming service platform. In addition, users can also use the add to music application function from the artist details page. Users will need to manually select their preferred music streaming service when they click the button for the first time, and this will be set as the default option subsequently. Users can choose a different streaming service when adding music if they wish

Cider is an alternative Apple Music desktop client, but features are missing from iTunes Cider is an alternative Apple Music desktop client, but features are missing from iTunes Apr 13, 2023 am 11:04 AM

Apple Music is now available on multiple platforms, including not only Apple operating systems, but also Android and Windows. However, on Windows, the Apple Music experience is far from optimal as users are still dependent on iTunes. With this in mind, a team of developers created Cider—a new open source Apple Music client for Window, Linux, and even macOS. Like many other Apple Music clients, Cider is based on Apple's official MusicKit API. The application is developed using El

Solution to PHP Fatal error: Class 'DOMDocument' not found in Solution to PHP Fatal error: Class 'DOMDocument' not found in Jun 23, 2023 am 11:16 AM

When using PHP to develop web applications, we often encounter error messages similar to "PHPFatalError: Class'DOMDocument'notfoundin". This error means that the PHP parser did not find the DOMDocument class and therefore could not load it. This usually happens in applications that need to work with XML and HTML documents. Below, we introduce several solutions to resolve “PHPFatalError:

Will iOS 16 bridge the gap between iPhone and Android with this Apple Music feature? Will iOS 16 bridge the gap between iPhone and Android with this Apple Music feature? May 12, 2023 pm 04:58 PM

AppleMusic is my go-to streaming music service, and I’ve tried them all. 85 reviews from a few months ago Spotify has its strengths, but due to its insistence on merging podcasts and music, it hasn't become a strong music streaming app. But having said that, Spotify (and even the AppleMusic app on Android) has one feature that the iOS version of AppleMusic lacks: seamless playback. Back in June 2020, AppleMusic on Android added support for seamless playback...but the feature is still not found in AppleMusic for iOS

See all articles