php heredoc原文檔和nowdoc文法

來源:互聯網
上載者:User
Heredoc原文檔和nowdoc文法使用情境代碼

                Current To-Do List      ';            foreach($parent as $task_id => $todo) {              echo << $todo  EOT;                if (isset($tasks[$task_id])) { // 如果當前id有子任務則遞迴建立菜單                  make_list($tasks[$task_id]);              }                echo "";          }            echo '';      }        $db = mysqli_connect('192.168.31.172' ,'root', 'root', 'phpadvanced');      mysqli_query($db, "set names utf8");        if (($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST['tasks']) && is_array($_POST['tasks']) && !empty($_POST['tasks'])) {            $q = 'UPDATE tasks SET date_completed=NOW() WHERE task_id IN (';          foreach($_POST['tasks'] as $task_id => $v) {              $q .= $task_id.', ';          }          $q = substr($q, 0, -2) . ')';            $r = mysqli_query($db, $q);            if(mysqli_affected_rows($db) == count($_POST['tasks'])) {              echo '

選擇的任務已經標記完成

'; } else { echo '

選擇的任務不能被標記為完成

'; } } $q = 'SELECT task_id, parent_id, task FROM tasks WHERE date_completed="0000-00-00 00:00:00" ORDER BY parent_id, date_added ASC'; $r = mysqli_query($db, $q); $tasks = array(); while (list($task_id, $parent_id, $task) = mysqli_fetch_array($r, MYSQLI_NUM)) { $tasks[$parent_id][$task_id] = $task; } //echo '
'.print_r($tasks,1).'
'; // 這是原文檔, heredoc格式 echo <<點擊檢查框, 標記為完成. (任務本身已經所有的子任務都將不會出現在這個列表)

EOT; ?>
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.