Answer the question
In order to leave comments, you need to log in
Where is the variable overwritten?
Hello.
There is this code:
case 'order':
$orderObj = new orderHandler($first_name, $last_name, $phone, $adress, $email, $message, $order);
$msg = "Имя: {$orderObj->getFirstName()} <br>";
$msg .= "Телефон: {$orderObj->getPhone()} <br>";
$msg .= "Заказ: {$orderObj->getOrder(false)} <br>";
$msg .= "Адрес: {$orderObj->getAdress()} <br>";
break;
}
$arOrder = [
'order' => $orderObj->getOrder(false),
];
public function getOrder($toString){
$order_string = $this->order;
if($toString){
$ar = array();
foreach($order_string as $item){
if($item == ''){
unset($item);
}
else{
$ar[] = $item;
}
}
$order_string = implode(',', $ar);
return $order_string;
}else{
return $this->order;
}
}
Answer the question
In order to leave comments, you need to log in
You have an orderHandler object in it, apparently (you did not provide the code of the entire class) there is a public variable order. On the first call it is an array, on the second it is a string. What is there specifically - xs. Give the whole code, or create a new instance of the object each time you access it.
VAR_DUMP in your hands and go ahead, in this section of the code a lot of things happen "behind the scenes", until you find out where the value has changed, pointing your finger in different directions is useless.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question