php,html5,wordpress,save,file-put-contents
For Future Reference here how to find the path: foreach ($attachments as $key => $attachment) { $name = $attachment['name']; $contents = $attachment['attachment']; file_put_contents(STYLESHEETPATH . '/email_attachments/' . $name, $contents); } ...
php,path,relative-path,file-put-contents
Alright, after one big headace, I've found the solution, given by @naviciroel I got the same error before but I don't know if this solution of mine works on your problem you need to remove the "\0" try replace it: $cleaned = strval(str_replace("\0", "", $buttons_first)); ...
You're only writing to the file if it exists and it's old. You should change the if so it writes to it if it doesn't exist as well. <?php $cache_file = 'cachemenu/content.cache'; if(!file_exists($cache_file) || time() - filemtime($cache_file) > 86400) { ob_start(); include 'includes/menu.php'; $buffer = ob_get_flush(); file_put_contents($cache_file, $buffer); } else...
php,file-get-contents,file-put-contents
This line file_get_contents('includes/menu.php'); will just read the php file, without executing it. Use this code instead (which will execute the php file and save the result into a variable): ob_start(); include 'includes/menu.php'; $buffer = ob_get_clean(); And then, just save the retrieved content ($buffer) into file file_put_contents($cache_file, $buffer); ...
Replace $codes_array = array_filter($codes_array, 'trim'); with $codes_array = array_map('trim', $codes_array); Otherwise, only the last element will not have \n at the end....