Answer the question
In order to leave comments, you need to log in
How to optimize the code, make it more professional?
$tableHTML = '<div class="scaleInTop">' . "\n";
$tableHTML .= '<div class="borderedBlock">' . "\n";
$tableHTML .= '<table class="table table-bordered align-middle">' . "\n";
$tableHTML .= ' <tr class="tableGreen text-center">' . "\n";
$tableHTML .= ' <td colspan="3">Карточка торговой точки</td>' . "\n";
$tableHTML .= ' <td>Дата создания: ' . date('d.m.Y', strtotime($callCompanyData['result']['DATE_CREATE'])) . '</td>' . "\n";
$tableHTML .= ' <td>Дата изменения: ' . date('d.m.Y H:i:s', strtotime($callCompanyData['result']['DATE_CREATE'])) . '</td>' . "\n";
$tableHTML .= ' </tr>' . "\n";
$tableHTML .= ' <tr class="tableGrey">' . "\n";
$tableHTML .= ' <td>Наименование Компании</td>' . "\n";
$tableHTML .= ' <td colspan="4">' . (!empty($callCompanyData['result']['TITLE']) ? $callCompanyData['result']['TITLE'] : ' ') . '</td>' . "\n";
$tableHTML .= ' </tr>' . "\n";
$tableHTML .= ' <tr class="tableGrey">' . "\n";
$tableHTML .= ' <td>Торговая точка</td>' . "\n";
$tableHTML .= ' <td colspan="4">' . (!empty($callCompanyData['result']['UF_CRM_1587463057321']) ? $callCompanyData['result']['UF_CRM_1587463057321'] : ' ') . '</td>' . "\n";
$tableHTML .= ' </tr>' . "\n";
$tableHTML .= ' <tr class="tableGrey">' . "\n";
$tableHTML .= ' <td>Телефон</td>' . "\n";
$tableHTML .= ' <td colspan="2">' . (!empty($collectedPhones) ? $collectedPhones : ' ') . '</td>' . "\n";
$tableHTML .= ' <td>E-Mail</td>' . "\n";
$tableHTML .= ' <td colspan="2">' . (!empty($collectedEmails) === true ? $collectedEmails : ' ') . '</td>' . "\n";
$tableHTML .= ' </tr>' . "\n";
$tableHTML .= ' <tr class="tableGrey">' . "\n";
$tableHTML .= ' <td>Фактический адрес</td>' . "\n";
$tableHTML .= ' <td colspan="4">' . (!empty($callCompanyData['result']['UF_CRM_1587463057321']) ? $callCompanyData['result']['UF_CRM_1587463057321'] : ' ') . '</td>' . "\n";
$tableHTML .= ' </tr>' . "\n";
$tableHTML .= '</table>' . "\n";
$tableHTML .= '</div>' . "\n";
Answer the question
In order to leave comments, you need to log in
All these punctuation marks don't dazzle in your eyes
1. Do not write HTML inside PHP, but vice versa - PHP inside HTML.
2. Use the null operator
3. Escape the output by default
i.e.
<tr class="tableGrey">
<td>Фактический адрес</td>
<td colspan="4"><?= htmlspecialchars($callCompanyData['result']['UF_CRM_1587463057321']) ?? ' ') ?></td>
</tr>
<tr class="tableGrey">
<td>Фактический адрес</td>
<td colspan="4">{{ callCompanyData.result.UF_CRM_1587463057321 ?? ' ' }}</td>
</tr>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question