首页 > 解决方案 > 更新 CF7 后错误通知数组到字符串的转换

问题描述

我需要有关以下错误的帮助

Notice: Array to string conversion in /www/test_123/public/wp-content/plugins/test-functions/match-functions.php on line 302

下面是写在 301 和 302 行的,不知道哪里错了。当我将联系表 7 更新到最新版本时会发生这种情况,但在 5.1.6 上没有这样的错误。

$location = WC_Geolocation::geolocate_ip();
$p1_dob = $your_birth_year . "-" . $your_birth_month . "-" . $your_birth_day;
$p2_dob = $partners_birth_year . "-" . $partners_birth_month . "-" . $partners_birth_day;
$pmf_love_match_html_url = "https://primary.astrowebserver.net/v2/reports/CreateShortHTML/REL-NEW-DUALMATCH/?APIKEY=012bc72f-093a-4617-9432-0cbb55662ad7&P1FirstName=" . $your_first_name . "&P1DOB=" . $p1_dob . "&P1Sex=" . $your_gender . "&P1Country=" . $location['country'] . "&P2FirstName=" . $partners_first_name . "&P2DOB=" . $p2_dob . "&P2Sex=" . $partners_gender . "&P2Country=" . $location['country'];

标签: phpwordpresscontact-form-7

解决方案


您正在将不同的变量附加到string. 其中一些变量不是类型string(而是一个array),因此不能附加到字符串。

$string_val = "foo";
$result = "-" . $string_val . "-" // works fine

$array_val = [
    "foo" => "bar",
    "bar" => "foo",
];
$result = "-" . $array_val . "-" // 'Notice: Array to string conversion ...'

推荐阅读