【问题标题】:How to solve this array to string conversion error如何解决这个数组到字符串的转换错误
【发布时间】:2018-03-28 16:26:13
【问题描述】:

我有 magebridge 的 magento 从 Joomla 进入该站点。 Magebridge.php 导致此错误:

注意:mysite/magebridge.php 第 54 行中的数组到字符串的转换

注意:mysite/magebridge.php 第 55 行中的数组到字符串转换

// Determine the Mage::app() arguments from the bridge
$app_value = (string) $magebridge->getMeta('app_value');
$app_type = (string) $magebridge->getMeta('app_type');

// Doublecheck certain values
if($app_type == 'website' && $app_value != 'admin') $app_value = (int)$app_value;
if($app_value == 'admin') $app_type = null;`

我该如何解决这个问题?有人有想法可以帮助我前进吗?谢谢!

【问题讨论】:

  • 检查$magebridge->getMeta('app_value') 返回的内容。我想它是数组。
  • 感谢您的快速回答,我对此很陌生,所以我不确定如何准确检查?
  • print_r, var_dump, 谷歌。

标签: php arrays string


【解决方案1】:

您可以使用逗号连接数组中的所有项目:

if(is_array($magebridge->getMeta('app_value'))) {
    $app_value = implode(',', $magebridge->getMeta('app_value'));
}

或者将它们转换为 JSON:

$app_value = json_encode($magebridge->getMeta('app_value'));

【讨论】:

    猜你喜欢
    • 2020-10-17
    • 2013-11-29
    • 2023-03-18
    • 2019-03-23
    • 2018-09-16
    • 2015-02-26
    相关资源
    最近更新 更多