php - Use fwrite to create an .md file -


i wondering if there way use fwrite() create .md file. creating blog team needs upload content without me typing out. content in markdown via .md file each post. trying make web page take content , create .md file it. right have proof test running , trying save .md file. however, when try change extension .md keep getting errors. i'm kinda php noob apricated.

tldr

i'm wondering why (fwrite("newfile.md", "w") or die("unable create file!") throw error while using .txt won't.

code

<?php $myfile = fwrite("newfile.md", "w") or die("unable create file!"); $txt = "john doe\n"; fwrite($myfile, $txt); $txt = "jane doe\n"; fwrite($myfile, $txt); fclose($myfile); ?> 

your issue aren't opening/creating file, you're attempting write it. need use fopen() before write it:

$myfile = fopen("newfile.md", "w") or die("unable create file!"); $txt = "john doe\n"; fwrite($myfile, $txt); $txt = "jane doe\n"; fwrite($myfile, $txt); fclose($myfile); 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -