php - Newline is not coming while echoing -



php - Newline is not coming while echoing -

this question has reply here:

why browser renders newline space? 5 answers

i have started learning php. in first code newline not coming properly. have gone through php doc, still i'm not getting problem.

<?php # echoing echo "hello world php \n"; echo "concatenation in php done using ." . "vivek kumar" . "learning php"; # variable basics $name = "vivek kumar"; $age = 26; echo "my name $name , age $age ."; echo 'my name '. $name . ' , age ' . $age . '.'; ?>

output:

hello world php concatenation in php done using .vivek kumarlearning phpmy name vivek kumar , age 26 .my name vivek kumar , age 26.

you can utilize nl2br convert new line (\n) line break (<br>).

from http://php.net/manual/en/function.nl2br.php:

string nl2br ( string $string [, bool $is_xhtml = true ] )

returns string <br /> or <br> inserted before newlines (\r\n, \n\r, \n , \r).

or can utilize line break, others have suggested. nl2br handy when showing text form text area.

php

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -