efficiency when displaying data with PHP

2

As a result of making a web page, a question has arisen. At the moment of showing on screen some type of information by echo with php how would it be better to show this data, in terms of efficiency?

  • Showing everything with a single echo :

    echo '<table><tbody><tr><th></th></tr></tbody></table>';
    
  • Showing everything with several echo :

    echo '<table>';
    echo '<tbody>';
    echo '<tr>';
    echo '<th>';
    echo '</th>';
    echo '</tr>';
    echo '</tbody>';
    echo '</table>';
    
  • asked by gmarsi 01.06.2017 в 23:24
    source

    1 answer

    2

    Obviously the ideal is to do a single echo.

    You get better performance by using single quotes than double quotes, since in doubles the php interpreter first looks to replace some variable inside double quotes.

    Using variables to store and do a single echo later is slower than doing several echos without using variables.

    Anyway, think that we are talking about micro-seconds. So do not get too complicated in that aspect.

    You can see phpbench.com time comparisons for each of them.

        
    answered by 07.06.2017 / 11:08
    source