In this question on SO, the consensus seems to be that creating multiple objects is superior in C#. I am wondering if that is also true for PHP. I have the following code: $data_transfer = new \V1\DataTransfer();        foreach ($pending_jobs as $job) {            $data_transfer->build_points_data_from_selected_csv_data($job->notes);            $data_transfer->update_database_with_points_data();        }Clearly the $data_transfer instance has important state information as evidenced by the two calls. However, the first call should overwrite all relevant state information.  The alternative to the above is the following code:foreach ($pending_jobs as $job) {    $data_transfer = new \V1\DataTransfer();    $data_transfer->build_points_data_from_selected_csv_data($job->notes);    $data_transfer->update_database_with_points_data();    unset($data_transfer);}Intuition says that this method should be a bit slower since I have to instantiate $data_transfer many times. The class is not huge; it's only 500 lines of code, so performance should probably not be hugely impacted. In general, is there a best practice for instantiating objects inside or before a loop? Or is it purely subjective(ie choose option 1 if performance is of more importance and choose option 2 if you cannot guarantee that state information will not be overwritten )?
Create an instance every loop or use one instance repeatedly?
php