Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created January 26, 2016 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/fc9558899bc3f89fe247 to your computer and use it in GitHub Desktop.
Save tommcfarlin/fc9558899bc3f89fe247 to your computer and use it in GitHub Desktop.
[WordPress] Touch a File (Before Creating It)
<?php
// Assume that $name is specified earlier in the code
$filename = dirname( __FILE__ ) . "/$name.json";
// If the is able to be touched, we're good to go...
if ( touch ( $filename ) ) {
// We're able to write to the file
} else {
// There was a problem trying to write to the file
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment