There is a line, how to insert a space between variables?

<p class="p_teacher_reg">ФИО: <?php echo $name_teacher, $surname_teacher, $last_name_teacher; ?></p> 

    4 answers 4

    In this particular case it does not matter, but from the point of view of saving memory, it is more optimal:

     <p class="p_teacher_reg">ФИО: <?php echo $name_teacher, ' ', $surname_teacher, ' ', $last_name_teacher; ?></p> 

    Since the string concatenation operator " . " And when join / implode creates a temporary variable in which all incoming lines are copied, and with sufficiently long lines (in the example, $name_teacher , $surname_teacher and $last_name_teacher ), there may be a shortage of memory.

      For example:

       echo $name_teacher.' '.$surname_teacher.' '.$last_name_teacher; 

      It is possible so:

       echo join(' ', array( $name_teacher, $surname_teacher, $last_name_teacher ) ); 

        Non-breaking space - &nbsp;

           <?php echo "{$name_teacher}, {$surname_teacher}, {$last_name_teacher}"; ?> 

          if I am not mistaken