如何將下面的代碼中的php函數轉換爲非函數。如何將PHP函數轉換爲非函數?
<?php
require_once ('./mysqli_connect.php'); // Connect to the db.
function make_list ($parent)
{
global $tasks;
echo '<ol>';
foreach ($parent as $task_id => $todo)
{
echo "<li>$todo";
if (isset($tasks[$task_id]))
{
make_list($tasks[$task_id]);
}
echo '</li>';
}
// Close the ordered list:
echo '</ol>';
}
$mysqli = new mysqli("localhost", "root", "", "sitename");
$dbc = mysqli_query($mysqli,"SELECT task_id, parent_id, task FROM tasks WHERE date_completed='0000-00-00 00:00:00' ORDER BY parent_id, date_added ASC");
if (!$dbc)
{
// There was an error...do something about it here...
print mysqli_error();
}
$tasks = array();
while (list($task_id, $parent_id, $task) = mysqli_fetch_array($dbc, MYSQLI_NUM))
{
// Add to the array:
$tasks[$parent_id][$task_id] = $task;
}
make_list($tasks[0]);
mysqli_close(); // close the connection
// Include the html footer
include('./includes/footer.html');
?>
即使我沒有發佈的代碼的其餘部分是非函數形式,最好還是留下這樣的代碼。
我認爲更好的問題是:爲什麼你會想要* *把你的函數成非功能? – hbw 2009-10-31 18:46:07