I came across an interesting scenario today. Like most developers, I like to add error_reporting(E_ALL) at the top of my PHP script. So, normally, I have my code like the following:
error_reporting(E_ALL);
immediately followed by html doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
On the output I was seeing blank lines for no reason. I usually comment error_reporting on our live sites, but keep it on Sandbox. I do this to avoid showing warning messages(if in any case it shows) on the live site. After going through my layout class, I realized error_reporting at the top of script adds a new line on the output. So, html output looks like the following (a blank extra line at top):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
An extra space/empty line at the top before the doctype. I don't want to see a new line at the top of HTML page, because it triggers IE-6 into Quirks mode. I had to change by script to the following
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><?php error_reporting(E_ALL); ?>
Which seemed to have solved my problem.
Add new comment