Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP remove <body><html>...</html></body> from echo output

I have a php script that does a query in my database and returns a string ( like "2" ). I print it using

print strip_tags('2');

but in the output of my browser I get :

<body><html>2</html></body>

Is there any way to prevent the tags from beiing printed? Is it maybe that the browser auto adds them?


For all those answering about strip_tags (" 2 ");

THIS IS WRONG:

I want a siple version.php with echo '2';

and nothing else. It prints the tags too. I don't have the tags and then try to print.


More explanation to those who try to get easy rep

my code is:

$str = '2';
print strip_tags($str);

and it prints

<html><head></head><body>2</body></html>
like image 552
Panos Avatar asked Oct 20 '22 20:10

Panos


1 Answers

It is not possible. The browser creates these elements automatically, without it there would not be any text flow(means nothing of this could be made visible).
You can just use this variable for any script, it won't include the HTML tags. This is only made by the browser to make it visible for you.

like image 103
nkmol Avatar answered Oct 23 '22 13:10

nkmol