我想知道PHP如何對待白色空間。減少我的php編碼中的空格PHP如何對待白色空間
- 會減少頁面加載時間嗎?
- 將減少我的視圖源中的空白空間嗎?
- 會減少我的程序編譯時間嗎?我的代碼
例
<?php
include('head.php');
-- Here is white space --
include('body.php');
-- Here is white space --
include('footer.php');
?>
內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>';
?>
我的生活符號化部
<?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查看源
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" />
行號1至4是空白像這樣的很多都是在我看來源
從PHP源中刪除空格除了可能的代碼可讀性之外,不會對任何事物產生明顯的影響。 –
我不認爲空白對性能有很大的作用..但是它們可以增加可讀性和文件大小。 –
瞭解PHP腳本的內容不會被客戶端下載 - 只是輸出。 – Marty