I would like to know how php treats white spaces. Reducing a white spaces in my php coding
- will reduce the page loading time ?
- Will reduce empty spaces in my view source ?
- Will reduce my program compiling time ?
Example of my code
<?php
include('head.php');
-- Here is white space --
include('body.php');
-- Here is white space --
include('footer.php');
?>
inside body.php
<?php
echo $lhs = '<div class="lhs">my content</div>';
white
spaces..
echo $main = '<div class="main">my content</div>';
white
spaces..
echo $footer ='<div class="footer">my content </div>';
?>
My live Coding Part
<?php include('config.php'); ?>
<!DOCTYPE HTML>
<html>
<?php include(ROOT.'head.php'); ?>
<body>
<div id="container">
<?php
// header items => logo , searchbar , compare , myaccount/login
include(ROOT.'headeritems.php');
//WEBSITE MENUS
include(ROOT.'sitemenus.php');
if ($page!="index"){ include(ROOT.'otherpagenotification.php'); }
?>
<div id="breadO" <?php echo ($page!="index")? 'class="bannerShd2"' :''; ?> >
<div id="bread">
<?php include(BREADCRUMBS); ?>
</div>
</div>
</div>
HTML View Source
1.
2.
3.
4.
5. <!DOCTYPE HTML>
6. <html>
7. <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Samsung Galaxy Note 3</title>
<link rel="shortcut icon" href="favicon.ico" />
<meta name="description" content="" />
<meta name="author" content="name" />
<meta name="rating" content="General" />
line number 1 to 4 is the white space like this many are in my view source