简体   繁体   中英

PHP echo adds a new line

Could somebody explain me why the PHP tags are giving me a linebreak?

And also, how can you delete this or stop this from happening, as it messes up my site.

An example I'm using on my site:

<?php include('assets/common/theme_header.php'); ?>

EDIT: This doesn't seem to happen when I'm using:

<?php ?> 

It does however seem to happen only when I'm using echo, which I also use on my include.

Example:

<?php echo "hello"; ?>

This still gives me a "linebreak", and it shows like this in Chrome development kit: 在此处输入图片说明

I had a similar situation where a php file on the server always echoed a space, then newline and then the actual echo. Like " \\n[someVariable]". I got rid of it by making sure the php file had no empty lines at the beginning or end of the file.

So no empty line before the <?php or after the end ?>

Perhaps your problem is related.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM