Skip to content

Instantly share code, notes, and snippets.

@koshiaaaaan
Created November 24, 2009 13:10
Show Gist options
  • Save koshiaaaaan/241862 to your computer and use it in GitHub Desktop.
Save koshiaaaaan/241862 to your computer and use it in GitHub Desktop.
<?php
// OSがサポートしているディレクトリの区切り文字
// Windowsでは\、Linuxでは/
$dir_sep = DIRECTORY_SEPARATOR ;
// このファイル自身(絶対パス)
$file = __FILE__ ;
// このファイルの置かれているディレクトリ(絶対パス)
$dir = dirname( __FILE__ ) ;
// 実行中のファイルが置かれているディレクトリ(絶対パス)
$realpath = realpath( '.' ) ;
// マジッククォート機能ON/OFFの差異をなくす(自作関数)
function normalize_magic_quotes_gpc( $arg ) {
if( is_array( $arg ) ) {
return array_map( 'normalize_magic_quotes_gpc', $arg ) ;
}
return ( get_magic_quotes_gpc() ) ? stripslashes( $arg ) : $arg ;
}
// htmlspecialcharsの配列対応ラッパー関数(自作関数)
// 基本的に出力時にのみ使うこと。
function h( $arg, $quote_style = ENT_QUOTES, $charset = '', $double_encode = true ) {
if( is_array( $arg ) ) {
foreach( $arg as $key => $var ) {
$arg[ $key ] = h( $var, $quote_style, $charset, $double_encode ) ;
}
return $arg ;
}
return htmlspecialchars( $arg, $escape, $charset, $double_encode ) ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment