php creating extra space in html page

2k Views Asked by At

I'm new to web development and I'm really stuck with this silly problem. When I insert php code before html code, something like this: <?php ...some code... ?><!doctype html><html>... it creates extra blank space on top of my page and 'pushes' whole content down. Is it possible to somehow avoid creating that extra space? It also makes extra space if the php code is in body part of html, for example if it's in between two paragraphs it will create extra space between that two paragraphs. Thanks for your answers!

1

There are 1 best solutions below

4
On

I guess this what happens

Your code like this

<?php
//your php code here
?>
<!DOCTYPE html PUBLIC "

You should have it like this

<?php
//your php code here
?><!DOCTYPE html PUBLIC "