开发者

Remove characters from HTTP response

开发者 https://www.devze.com 2023-01-29 12:42 出处:网络
in my ap开发者_StackOverflow中文版i system when the result is showed in plaintext, it looks like:

in my ap开发者_StackOverflow中文版i system when the result is showed in plaintext, it looks like: "the result\n"

i need to remove those " \n" and the result should contain just the result.

i set header('Content-type: text/plain'); for the result.

btw. my system is in PHP

UPDATE:

when i open the url in the browser it gives me the result but when i test the request with http://hurl.it the result is "the result\n"

i tried with trim and rtrim but didn't help


Best way is to go through your code and see if there are any whitespace characters before or after <? or ?>.

Or else, you could use output buffering.

Use at the absolute top of your code:

@ob_start();

And at absolute the bottom:

die(trim(@ob_get_clean()));


There are a number of reasons why this may happen, but a common one is the use of magic_quotes.

Are you able to check if magic quotes are switched on, and maybe turn them off if they are? You can read about magic quotes here.

Alternatively, you can try using the stripslashes command.


Just remove any leading and trailing whitespace with trim().

$string = trim($string);
0

精彩评论

暂无评论...
验证码 换一张
取 消