How to use php's ob_get_contents to print text to a .txt file

I want to collect data from a page through php and print it to a new .txt file.

I saw that using php’s ob_get_contents copies the data you want to copy from the page, but then how do I write those data to a .txt file living in kirby?

(I have in mind to usie github’s hook method to push it from a local repo to an online one).

ok fwrite() seems to do it. Sorry for the post.


You can also use Kirby’s $pages->create() and $page->update() methods to write data to Kirby content files. They will do all the formatting and writing for you.