In some place the method "falls":

fwrite($fc, "[1]"); $arOrders = $obmen->runObmenOrdersIn(); fwrite($fc, [2]"); 

Ie, the record "1" is, and "2" is no longer.

I put an exception in the method, hoping to find a place where something is wrong and get the error text:

 public function runObmenOrdersIn() { try{ $allOrders['NEW'] = $this->getOrdersLast('NEW'); $this->insertOrdersInDB($allOrders['NEW']); unset($allOrders['NEW']); $allOrders['CHANGED'] = $this->getOrdersLast('CHANGED'); $this->updateOrdersInDB($allOrders['CHANGED']); unset($allOrders['CHANGED']); $allOrders['CANCELED'] = $this->getOrdersLast('CANCELED'); $this->updateCanseledOrdersInDB($allOrders['CANCELED']); unset($allOrders['CANCELED']); } catch (Exception $ex) { return $ex->getMessage(); } } 

I write down what the method returns:

 $arOrders = $obmen->runObmenOrdersIn(); fwrite($fc, $arOrders); 

Is empty. Tell me how to implement it correctly?

  • if it is empty, then most likely it does not enter the exception, put a try - return at the end of the exception, to make sure ' - heff
  • Use debugging and step through the function. - Daniel Protopopov
  • fwrite($fc, [2]"); - haven't you forgotten the quote here? - Manitikyl
  • can just turn on error output? error_reporting = e_all , ini_set.display_errors = true - Lexx918
  • And how will I see them? This happens in production at the time of data exchange with 1C. - Sergey

2 answers 2

Inside the method, through each line write something like

 fwrite($fc, $alert"); exit(); 

where $ alert is just a line with text and delete it successively until you see that the next line is not displayed, and you will understand on which line everything “falls”

  • It is more important for me to understand what the error is. - Sergey
  • Well, as you find a line that knocks the work, make var_dump ('broken line'); find out what it returns, read the documentation, find out what it should return, what it should accept and everything in that spirit .. or go to the function that calls it with a line, do it all the same again and so on until you reach the reason .. think, pick and understand what the error is, so debug works)) there are no telepaths right there to know all your code in the method and the function called by looking at a couple of lines - Broouzer King

There is such a function register_shutdown_function , with its help you can catch all the errors and crashes. Use something like this:

 register_shutdown_function( "callback" ); function callback() { var_dump(error_get_last()); } $a='string'; $a->a();