chris
chris

Reputation: 649

PHP returning extra line returns

When posting from JS, PHP (5.3.8) returns some line returns in excess. For example:

if (isset($_POST['postId']) && $_POST['postId'] == "test") { 
    echo 'ok';
}

returns ok↵↵↵

Is this by design? How can I get rid of those line returns?

Upvotes: 1

Views: 359

Answers (2)

Milan
Milan

Reputation: 3325

... right below your

echo 'ok';

paste another snippet:

echo '--------new line------';

if the gap (extra returns) show between your first echo and the -----new line----- it would be more than strange:) However if it shows below the ------new line----- you have probably some extra HTML text (tags) below your PHP statement.

Upvotes: 1

xdazz
xdazz

Reputation: 160833

No, this is not by design. You have three newline output.

Try to delete the close tag of php ?>, if you don't have any html after php code.

Another way is just put exit; right after echo, you won't get newline again.

Upvotes: 5

Related Questions