我對我的網站的一些更新很滿意,但是我找不到我做錯了什么。
DB::beginTransaction();
try {
Log::debug('--創建--')。
Log::debug($responsible-> contactInfo)。
$firstName = isset($responsible-> firstName) ? $responsible->firstName : 'NoName'/span>。
$lastName = isset($responsible-> lastName) ? $responsible->lastName : $firstName;
$middleName = isset($responsible-> middleName) ? $responsible->middleName : ''/span>。
if (isset($responsible-> contactInfo) {
foreach ($responsible->contactInfo as $key => $value) {
if ($value && property_exists($value, 'type') & & $value->type == 'email') {
$email = $value->value。
}
if ($value && property_exists($value, 'type') & & $value->type == 'phone') {
$phone = preg_replace('/[^0-9]/', '', $value->value) 。
}
}
}
我處理這個資訊:
(
[id] => 1000005[/span
[firstName] => 測驗
[lastName] => 約翰
[中間名] => Smith
[contactInfo] => stdClass Object
(
[0] => stdClass Object
(
[type] => email
[值] => [email protected]
)
[1] => stdClass Object
(
[type] => phone
[value] => 380 67 777 7777
我得到了這個錯誤:
我得到了這個錯誤。
[2021-09-14 15:46:18] 生產。 INFO: 負責
[2021-09-14 15:46:18] 生產。 INFO: stdClass Object
(
[id] => 1000005 Object (
[firstName] => 測驗
[lastName] => 約翰
[中間名] => Smith
[contactInfo] => stdClass Object
(
[0] => stdClass Object
(
[type] => email
[值] => [email protected]
)
[1] => stdClass Object
(
[type] => phone
[value] => 380 67 777 77772021-09-14 15:46:18] 生產。 DEBUG: --- 創建 ---
[2021-09-14 15:46:18] 生產。 ERROR: unaught exception 'ErrorException' with message 'Object of class stdClass could not be converted to string' in /home/www/test/vendor/monolog/src/Monolog/Logger. php:329。
我希望有人能幫我解決這個問題。
uj5u.com熱心網友回復:
$responsible->contactInfo是一個stdClass實體,它不被記錄器所接受。
你必須把它轉換成一個陣列:
Log::debug($responsible-> contactInfo); // error
Log::debug((array) $responsible->contactInfo); // should works (logged as an array)
Log::debug(json_encode($responsible->contactInfo)); // should works (logged as json)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/306916.html
標籤:
上一篇:<p>我有兩個陣列,一個是selectedOption,另一個是defaultOption,如果selectedOptionid出現在defaultOption陣列的任何一個選項屬性中,那
