PHP致命错误:未捕获的错误:不能将stdClass类型的对象用作数组
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP致命错误:未捕获的错误:不能将stdClass类型的对象用作数组相关的知识,希望对你有一定的参考价值。
我目前正在尝试从下面发布的代码中获取ID。
Array
(
[0] => stdClass Object
(
[extraData] => stdClass Object
(
[temporaryUrlDomain] => stackstaging.com
[welcomeEmailRef] => 646883
)
[id] => 10954
[label] => Linux Unlimited
[limits] => stdClass Object
(
[domainContacts] => 1
[dns] => 1
[domainPrivacy] => 1
[nameservers] => 1
[pushTransfer] =>
[whois] => 1
[canSetQuotaNotification] =>
[dkimSignatures] =>
[highEmailNotification] => 0
[imapSync] => 1
[lowEmailNotification] => 0
[mailAutoresponders] => INF
[mailboxes] => INF
[mailCatchAllForwarders] => 1
[mailForwarders] => INF
[mailJunkFilterLogs] => 1
[mailJunkFilters] => 1
[maxMailboxSize] => 10240
[webmail] =>
[accessErrorLogs] => 1
[accountSummary] => 1
[additionalFtpUsers] => INF
[allowExternalSsl] => 1
[apps] => stdClass Object
(
[abantecart] => 1
[agoracart] => 1
[b2evolution] => 1
[buddypress] => 1
[cakephp] => 1
[cmsmadesimple] => 1
[concrete5] => 1
[coppermine] => 1
[craftcms] => 1
[craftysyntax] => 1
[dolphin] => 1
[dotproject] => 1
[drupal] => 1
[e107] => 1
[elgg] => 1
[fengoffice] => 1
[fluxbb] => 1
[formtools] => 1
[geeklog] => 1
[helpcenterlive] => 1
[iqdesk] => 1
[joomla] => 1
[limesurvey] => 1
[magento] => 1
[mambocms] => 1
[mantisbt] => 1
[matomo] => 1
[mediawiki] => 1
[modx] => 1
[moodle] => 1
[nucleus] => 1
[opencart] => 1
[openwebanalytics] => 1
[oscommerce] => 1
[osticket] => 1
[phpbb] => 1
[phpcoin] => 1
[phpformgenerator] => 1
[phpfreechat] => 1
[phpfusion] => 1
[phplist] => 1
[phpmyfaq] => 1
[phpnuke] => 1
[phprojekt] => 1
[piwigo] => 1
[prestashop] => 1
[prosper202] => 1
[reviveadserver] => 1
[roundcube] => 1
[serendipity] => 1
[silverstripecms] => 1
[simplemachinesforum] => 1
[slim] => 1
[squirrelmail] => 1
[sugarcrm] => 1
[tcexam] => 1
[textpattern] => 1
[troubleticketexpress] => 1
[typo3] => 1
[webcalendar] => 1
[wordpress] => 1
[zencart] => 1
)
[allFutureOneClick] =>
[awstats] => 1
[backups] => 1
[bandwidth] => INF
[blockVisitors] => 1
[cdnCaching] =>
[cdnOptimisation] =>
[cdnStatistics] =>
[customDocRoot] => 1
[customPrimaryDocRoot] =>
[directoryIndexing] => 1
[emailSummary] => 1
[fileManager] => 1
[filePermissions] =>
[freeSsl] => 1
[ftp] => 1
[googleTranslate] => 1
[hotlinkProtection] => 1
[mailDistributionLists] => INF
[malwareScan] =>
[manageAppPool] =>
[manageWpAdminUsers] =>
[manageWpChecksumReport] =>
[manageWpDatabase] => 1
[manageWpPlugins] =>
[manageWpSearchReplace] =>
[manageWpSiteSettings] =>
[manageWpStaging] =>
[manageWpThemes] =>
[manageWpUpdates] =>
[manageWpUsers] =>
[mysqlDatabases] => INF
[names] => 1
[nameserverCheck] => 1
[passwordProtectedDirectories] => 1
[phpConfig] => 1
[phpMyAdmin] => 1
[platformReinstall] => 1
[primaryFtpUnlock] => 1
[remoteMysql] => 1
[scheduledTasks] => 1
[sitemapGenerator] =>
[ssh] => 1
[statsBandwidth] =>
[statsDisk] =>
[switchPhpVersion] => 1
[temporaryURL] => 1
[timelineBackups] => 1
[usageInformation] =>
[webBuilder] => 1
[webRedirect] => 1
[webalizer] => 1
[webspace] => INF
[wpAdmin] =>
[domains] => 0
[subdomains] => 0
[mssqlDatabases] => INF
[bamboo] =>
[cdnCachin] =>
)
[platform] => linux
[installApps] => Array
(
)
[welcomeEmail] => Content-Type: text/html
Subject: Welcome To Your New Hosting
From: noreply@cloud-munch.com
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>​​</p>
<table style="font-family: 'Segoe UI', 'Segoe WP', 'Segoe UI WPC', Tahoma, Arial, sans-serif; color: #555;" border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#e9ecef">
<tbody>
<tr>
<td> </td>
</tr>
<tr>
<td align="center" valign="top">​​​​
<table border="0" width="600" cellspacing="0" cellpadding="20">
<tbody>
<tr>
<td align="center">{%if brand.hasLogo and brand.primaryBrandUrl %}<img src="{{brand.primaryBrandUrl}}/brandLogo" height="50" />{%endif%}
<h1>{% if brand.brandName %}{{brand.brandName}}{%endif%}</h1>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#fff">​
<p>Hi{% if contact.person_name %} {{contact.person_name}}{% endif %},</p>
<p>Welcome to your new web hosting with {% if brand.businessName %}{{brand.businessName}}{% else %}Us{% endif %}.</p>
<p>This email contains important information about your hosting account, so we recommend that you save it for future reference.</p>
<p> </p>
<p><strong>Your Hosting</strong></p>
<p>Domain Name: {{primarydomain}}</p>
<p>Account Setup Date: {{datecreated}}</p>
<p>Web Hosting Package Type: {{packagetype}}</p>
<p> </p>
<p><strong>{% if brandname %}{{brandname}}{% else %}StackCP{% endif %} Control Panel</strong> </p>
<p>Username: {{primarydomain}}</p>
<p>Password: {{password}} </p>
<p>Control Panel Login: <a href="{{brand.cpurl}}">{{brand.cpurl}}</a></p>
<p> </p>
<p><strong>FTP</strong></p>
<p>Username: {{ftpusername}} </p>
<p>Password: {{password}} </p>
<p>Server: {{ftpserver}}</p>
<p>To transfer your your website files, you can use FTP.</p>
<p>This needs to be unlocked first. </p>
<p>You can do this in {% if brandname %}{{brandname}}{% else %}StackCP{% endif %}, using these credentials:</p>
<p> </p>
<p><strong>Email</strong></p>
<p>Incoming Mail Server: {{mailserver}} </p>
<p>Outgoing Mailserver: {{mailserver}} </p>
<p>Webmail URL: <a href="{{webmailurl}}">{{webmailurl}}</a></p>
<p> </p>
<p>You can configure your email by logging in to {% if brandname %}{{brandname}}{% else %}StackCP{% endif %}, and selecting “Email accounts”</p>
<p>{% if brand.supportUrl and brand.supportEmailAddress %}If you have any issues, please go to {{ brand.supportUrl }} or email us at: {{ brand.supportEmailAddress }}{% endif %}</p>
<p>Thanks for your business.</p>
<p>{% if businessname %}{{businessname}}{% endif %}</p>
</td>
</tr>
<tr>
<td style="font-size: 10pt;" align="center">{% if brand.socialMedia.twitter %}<a href="https://twitter.com/{{brand.socialMedia.twitter}}"><img src="{{brand.primaryBrandUrl}}/assets/images/email/social-media/twitter.png" alt="Twitter" width="32" height="32" /></a>{% endif %} {% if brand.socialMedia.facebook %}<a href="https://facebook.com/{{brand.socialMedia.facebook}}"><img src="{{brand.primaryBrandUrl}}/assets/images/email/social-media/facebook.png" alt="Facebook" width="32" height="32" /></a>{% endif %} {% if brand.socialMedia.instagram %}<a href="https://www.instagram.com/{{brand.socialMedia.instagram}}"><img src="{{brand.primaryBrandUrl}}/assets/images/email/social-media/instagram.png" alt="Instagram" width="32" height="32" /></a>{% endif %} {% if brand.socialMedia.youtube %}<a href="https://www.youtube.com/{{brand.socialMedia.youtube}}"><img src="{{brand.primaryBrandUrl}}/assets/images/email/social-media/youtube.png" alt="YouTube" width="32" height="32" /></a>{% endif %} {% if brand.socialMedia.linkedin %}<a href="https://www.linkedin.com/{{brand.socialMedia.linkedin}}"><img src="{{brand.primaryBrandUrl}}/assets/images/email/social-media/linkedin.png" alt="Linkedin" width="32" height="32" /></a>{% endif %}</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
</tbody>
</table>
</body>
</html>
[passwordResetEmail] =>
)
[1] => stdClass Object
(
[extraData] => stdClass Object
(
[temporaryUrlDomain] =>
[welcomeEmailRef] =>
)
[id] => 10955
[label] => Windows Unlimited
[limits] => stdClass Object
(
[dns] => 1
[nameservers] => 1
[whois] => 1
[imapSync] => 1
[mailAutoresponders] => INF
[mailboxes] => INF
[mailCatchAllForwarders] => 1
[mailForwarders] => INF
[mailJunkFilterLogs] => 1
[mailJunkFilters] => 1
[maxMailboxSize] => 10240
[accessErrorLogs] => 1
[accountSummary] => 1
[additionalFtpUsers] => INF
[allowExternalSsl] => 1
[apps] => stdClass Object
(
[abantecart] => 1
[agoracart] => 1
[b2evolution] => 1
[buddypress] => 1
[cakephp] => 1
[cmsmadesimple] => 1
[concrete5] => 1
[coppermine] => 1
[craftcms] => 1
[craftysyntax] => 1
[dolphin] => 1
[dotproject] => 1
[drupal] => 1
[e107] => 1
[elgg] => 1
[fengoffice] => 1
[fluxbb] => 1
[formtools] => 1
[geeklog] => 1
[helpcenterlive] => 1
[iqdesk] => 1
[joomla] => 1
[limesurvey] => 1
[magento] => 1
[mambocms] => 1
[mantisbt] => 1
[mediawiki] => 1
[modx] => 1
[moodle] => 1
[nucleus] => 1
[opencart] => 1
[openwebanalytics] => 1
[oscommerce] => 1
[osticket] => 1
[phpbb] => 1
[phpcoin] => 1
[phpformgenerator] => 1
[phpfreechat] => 1
[phpfusion] => 1
[phplist] => 1
[phpmyfaq] => 1
[phpnuke] => 1
[phprojekt] => 1
[piwigo] => 1
[prestashop] => 1
[prosper202] => 1
[reviveadserver] => 1
[roundcube] => 1
[serendipity] => 1
[silverstripecms] => 1
[simplemachinesforum] => 1
[slim] => 1
[squirrelmail] => 1
[statusnet] => 1
[sugarcrm] => 1
[tcexam] => 1
[textpattern] => 1
[tomatocart] => 1
[troubleticketexpress] => 1
[typo3] => 1
[webcalendar] => 1
[wordpress] => 1
[zencart] => 1
[matomo] => 1
)
[awstats] => 1
[backups] => 1
[bandwidth] => INF
[blockVisitors] => 1
[customDocRoot] => 1
[directoryIndexing] => 1
[domainContacts] => 1
[domainPrivacy] => 1
[emailSummary] => 1
[fileManager] => 1
[freeSsl] => 1
[ftp] => 1
[googleTranslate] => 1
[hotlinkProtection] => 1
[mailDistributionLists] => INF
[manageAppPool] => 1
[manageWpDatabase] => 1
[mssqlDatabases] => INF
[mysqlDatabases] => INF
[nameserverCheck] => 1
[names] => 1
[passwordProtectedDirectories] => 1
[platformReinstall] => 1
[phpConfig] => 1
[phpMyAdmin] => 1
[primaryFtpUnlock] => 1
[remoteMysql] => 1
[scheduledTasks] => 1
[ssh] => 1
[switchPhpVersion] => 1
[temporaryURL] => 1
[timelineBackups] => 1
[webalizer] => 1
[webBuilder] => 1
[webRedirect] => 1
[webspace] => INF
[malwareScan] =>
[manageWpPlugins] =>
[manageWpThemes] =>
[manageWpUsers] =>
[manageWpAdminUsers] =>
[manageWpSiteSettings] =>
[manageWpStaging] =>
[manageWpChecksumReport] =>
[manageWpSearchReplace] =>
[manageWpUpdates] =>
[filePermissions] =>
[bamboo] =>
[sitemapGenerator] =>
[cdnCachin] =>
[cdnOptimisation] =>
[cdnCaching] =>
[cdnStatistics] =>
)
[platform] => windows
[installApps] => Array
(
)
[welcomeEmail] =>
[passwordResetEmail] =>
)
[2] => stdClass Object
(
[extraData] => stdClass Object
(
[temporaryUrlDomain] =>
[welcomeEmailRef] =>
)
[id] => 10956
[label] => WordPress Unlimited
[limits] => stdClass Object
(
[dns] => 1
[nameservers] => 1
[whois] => 1
[imapSync] => 1
[mailAutoresponders] => INF
[mailboxes] => INF
[mailCatchAllForwarders] => 1
[mailForwarders] => INF
[mailJunkFilterLogs] => 1
[mailJunkFilters] => 1
[maxMailboxSize] => 10240
[accessErrorLogs] => 1
[accountSummary] => 1
[additionalFtpUsers] => INF
[allowExternalSsl] => 1
[apps] => stdClass Object
(
[abantecart] => 1
[agoracart] => 1
[b2evolution] => 1
[buddypress] => 1
[cakephp] => 1
[cmsmadesimple] => 1
[concrete5] => 1
[coppermine] => 1
[craftcms] => 1
[craftysyntax] => 1
[dolphin] => 1
[dotproject] => 1
[drupal] => 1
[e107] => 1
[elgg] => 1
[fengoffice] => 1
[fluxbb] => 1
[formtools] => 1
[geeklog] => 1
[helpcenterlive] => 1
[iqdesk] => 1
[joomla] => 1
[limesurvey] => 1
[magento] => 1
[mambocms] => 1
[mantisbt] => 1
[mediawiki] => 1
[modx] => 1
[moodle] => 1
[nucleus] => 1
[opencart] => 1
[openwebanalytics] => 1
[oscommerce] => 1
[osticket] => 1
[phpbb] => 1
[phpcoin] => 1
[phpformgenerator] => 1
[phpfreechat] => 1
[phpfusion] => 1
[phplist] => 1
[phpmyfaq] => 1
[phpnuke] => 1
[phprojekt] => 1
[piwigo] => 1
[prestashop] => 1
[prosper202] => 1
[reviveadserver] => 1
[roundcube] => 1
[serendipity] => 1
[silverstripecms] => 1
[simplemachinesforum] => 1
[slim] => 1
[squirrelmail] => 1
[statusnet] => 1
[sugarcrm] => 1
[tcexam] => 1
[textpattern] => 1
[tomatocart] => 1
[troubleticketexpress] => 1
[typo3] => 1
[webcalendar] => 1
[wordpress] => 1
[zencart] => 1
[matomo] => 1
)
[awstats] => 1
[backups] => 1
[bandwidth] => INF
[blockVisitors] => 1
[customDocRoot] => 1
[directoryIndexing] => 1
[domainContacts] => 1
[domainPrivacy] => 1
[emailSummary] => 1
[fileManager] => 1
[freeSsl] => 1
[ftp] => 1
[googleTranslate] => 1
[hotlinkProtection] => 1
[mailDistributionLists] => INF
[manageAppPool] => 1
[manageWpDatabase] => 1
[mssqlDatabases] => INF
[mysqlDatabases] => INF
[nameserverCheck] => 1
[names] => 1
[passwordProtectedDirectories] => 1
[platformReinstall] => 1
[phpConfig] => 1
[phpMyAdmin] => 1
[primaryFtpUnlock] => 1
[remoteMysql] => 1
[scheduledTasks] => 1
[ssh] => 1
[switchPhpVersion] => 1
[temporaryURL] => 1
[timelineBackups] => 1
[webalizer] => 1
[webBuilder] => 1
[webRedirect] => 1
[webspace] => INF
[malwareScan] =>
[manageWpPlugins] =>
[manageWpThemes] =>
[manageWpUsers] =>
[manageWpAdminUsers] =>
[manageWpSiteSettings] =>
[manageWpStaging] =>
[manageWpChecksumReport] =>
[manageWpSearchReplace] =>
[manageWpUpdates] =>
[filePermissions] =>
[bamboo] =>
[sitemapGenerator] =>
[cdnCachin] =>
[cdnOptimisation] =>
[cdnCaching] =>
[cdnStatistics] =>
)
[platform] => wordpress
[installApps] => Array
(
)
[welcomeEmail] =>
[passwordResetEmail] =>
)
)
我尝试使用下面的代码,但没有运气,有人有任何想法吗?
echo $domains[0]["id"];
我收到以下错误,
致命错误:未捕获错误:无法将stdClass类型的对象用作/home/sites/10a/6/6dc3805467/public_html/hosting-api/api/lib/getid.php:15中的数组:堆栈跟踪:#0 {main }在第15行的/home/sites/10a/6/6dc3805467/public_html/hosting-api/api/lib/getid.php中抛出
答案
访问对象时,我们使用'->',而您使用的方式是访问数组键。
请尝试使用以下代码。
echo $domains[0]->id;
域是对象的数组,因此我们使用上述方法访问键及其值。
以上是关于PHP致命错误:未捕获的错误:不能将stdClass类型的对象用作数组的主要内容,如果未能解决你的问题,请参考以下文章
PHP 致命错误:未捕获的错误:调用字符串中的成员函数 diff()
为啥我收到 PHP 致命错误:未捕获的错误:找不到类“MyClass”? [复制]
PHP“致命错误:未捕获错误:调用成员函数prepare()为null”
致命错误:未捕获的错误:调用未定义的函数 mssql_query() [重复]
如何解决 PHP 致命错误:未捕获的错误:在 laravel 版本更新时调用未定义的方法 Illuminate\Container\Container::basePath() 错误?