colap Posted February 5, 2011 Share Posted February 5, 2011 Can't echo newline. <?php class Myclass{ public $var_one=100; public $var_two=400; function printvalues(){ echo 'Inside printvalues function\n'; echo '$var_one: '.$this->var_one.'\n'; } } $obj=new Myclass(); $obj->printvalues(); echo '$var_two: '.$obj->var_two.'\n'; ?> Link to comment https://forums.phpfreaks.com/topic/226758-simple-problemits-not-echoing-newline/ Share on other sites More sharing options...
kenrbnsn Posted February 5, 2011 Share Posted February 5, 2011 The \n isn't interpreted when enclosed in single quotes, use double quotes. This <?php echo '\n'; ?> will echo the string \n, while this <?php echo "\n"; ?> will produce a newline character. But the newline character isn't seen by the browser as a newline, for that you need to echo the <br> tag. Ken Link to comment https://forums.phpfreaks.com/topic/226758-simple-problemits-not-echoing-newline/#findComment-1170158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.