# 如何在Controller中取得view的html字串

- 發布日期：2021-06-10
- 作者：Ronnie Chang
- 分類：程式設計
- 關鍵字：Laravel view、 render

> get view html in controller laravel?如何在Controller中取得View Blade的HTML字串呢?

當我們需要Blade內的HTML內容，可能用作於產生PDF而不是顯示在畫面上。那麼我們如何在Controller中取得view的html字串?

```
$html = view('users.edit', compact('data'))->render();
```

 

## 熱門文章

- [Bootstrap5 釋出Beta版本](/article/87)：經歷了多個alpha版本後Bootstrap 5 beta版於2020年12月7日釋出
- [【網頁設計】網頁中文字型推薦](/article/61)：挑選適合的網站字型，可以為您的網站質感加分不少，到底應該如何挑選合適的字型呢?接下來介紹由免費中文字型--思源黑體。
- [HTTP Strict Transport Security (HSTS) not implemented 調整教學](/article/93)：HTTP Strict Transport Security (HSTS) not implemented 未使用嚴格安全傳輸(HSTS)，教你如何設定
- [MySQL 查詢、插入、更新、刪除基本語法](/article/69)：對於 MySQL 資料庫資料操作的基本語法大全
- [Laravel使用$loop說明](/article/26)：在Laravel 5.3版本起有了新的功能 循環變量 loop

使用foreach迴圈時可以在迴圈內使用$loop得到迴圈內的訊息

## 連結

- [回文章列表](/article)
- [聯絡我們](/contact)
