本教程將教會您如何調試文件和應用程序以便從您的PHP代碼中獲取最大的效率和準確性。Zend Studio的調試功能能夠檢查並診斷PHP代碼在本地或遠程服務器上的錯誤。調試器容許您經過設置斷點、暫停啓動的程序、單步調試代碼和檢查變量的內容來控制程序的執行。調試應該在您的腳本和應用程序已經充分造成試用和測試階段試用。php
接下來,咱們將經過添加一個新的PHP文件到項目中,以此來開始開發咱們的應用程序。服務器
1. 在PHP Explorer視圖中,選擇新建立的項目。測試
2. 右鍵單擊,選擇New | PHP File。PHP File建立對話框將會顯示。spa
3. 新文件命名爲'debug.php',而後單擊Finish。這樣新的文件添加成功,而且會顯示在PHP Editor和PHP Explorer視圖中。.net
4. 將如下的示例代碼粘貼到新文件中:debug
<
h1
>Debug Demo</
h1
>
調試
\n";
code
print "\n";
htm
print "\n";
print "\n";
print "\n";
}
}
display_workers();
echo $undefined_variable;
?>
<
table
border
=
"1"
width
=
"700"
>
<
tbody
><
tr
bgcolor
=
"red"
>
<
th
>Name</
th
>
<
th
>Address</
th
>
<
th
>Phone</
th
>
</
tr
>
<!--?php
$db = array(
array ("John", "E 10th St., NYC, NY 23742", "(212) 555-4456"),
array ("Francois", "12 Bd. de Grenelle, Paris, 74897","(33) 433-544"),
array ("Klaus", "312 Beethoven St., Frankfurt, Germany", "(44) 332-8065"),
array ("Shirly", "72 Independence St., Tel Aviv, Israel 67283", "(972) 156-7777"),
array ("Bill", "127 Maine St., San Francisco, CA 90298", "(415) 555-6565")
);
/**
@return string
@param i int
@desc Returns 'white' for even numbers and 'yellow' for odd numbers
*/
function row_color($i)
{
$bgcolor1 = "white";
$bgcolor2 = "yellow";
if ( ($i % 2) == 0 ) {
return $bgcolor1;
} else {
return $bgcolor2;
}
}
/**
@return void
@desc Displays a table of the workers
*/
function display_workers()
{
global $db;
for ($i=0 ; $i < count($db); $i++) {
$worker_data = $db[$i];
$worker_name = $worker_data[0];
$worker_address = $worker_data[1];
$worker_phone = $worker_data[2];
print "<tr bgcolor=\"".row_color($i)."\"-->
<
tr
><
td
>$worker_name</
td
><
td
>$worker_address</
td
><
td
>$worker_phone</
td
></
tr
></
tbody
></
table
>
有興趣的朋友能夠點擊查看更多相關教程>>