その他の関数

not_found($view="404")

function not_found($view="404"){
  header("Status: 404 Not Found");
  if(!view($view)) echo "404 not found.";
  exit;
}

h($str)

function h($str){
  return htmlspecialchars($str);
}

el($object, $key, $default=[])

function el($array, $key, $default=null){
  if(is_array($array)){
    return isset($array[$key]) ? $array[$key] : $default;
  }else if(is_object($array)){
    return isset($array->$key) ? $array->$key : $default;
  }else{
    return false;
  }
}
// usage
$array = ["a" => 1];

el($array, "a")
=> 1

el($array, "a", 100)
=> 1

el($array, "b")
=> null

el($array, "b", 100)
=> 100

pathto($path, $display=false)

redirect($url, $code=302)

external_redirect($url, $code=302)

capture