Skip to content

Instantly share code, notes, and snippets.

@Restoration
Created October 26, 2016 10:59
Show Gist options
  • Select an option

  • Save Restoration/0540fa9237e3d0a53b065ab682966d65 to your computer and use it in GitHub Desktop.

Select an option

Save Restoration/0540fa9237e3d0a53b065ab682966d65 to your computer and use it in GitHub Desktop.
ファイルが存在するかチェックする
<?php
/**
* ファイルが存在するかチェックする
*
* @param string
* @param string
* @return boolean
*/
function check_file_exists($dir,$file_name){
if(substr($dir,-1) !== "/"){
$dir .= "/";
}
echo "test";
$file_name = $dir.$file_name;
if(file_exists($file_name)){
return true;
} else {
return false;
}
}
$dir = "test";
$name = "sample_image.jpgf";
var_dump(check_file_exists($dir,$name));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment