Skip to content

Instantly share code, notes, and snippets.

<?php
// OSがサポートしているディレクトリの区切り文字
// Windowsでは\、Linuxでは/
$dir_sep = DIRECTORY_SEPARATOR ;
// このファイル自身(絶対パス)
$file = __FILE__ ;
// このファイルの置かれているディレクトリ(絶対パス)
$dir = dirname( __FILE__ ) ;
// 実行中のファイルが置かれているディレクトリ(絶対パス)
$realpath = realpath( '.' ) ;
<?php
require_once 'Zend/Filter/Interface.php';
class My_Filter_NormalizeMagicQuotesGpc implements Zend_Filter_Interface
{
protected $_flag ;
public function __construct( $flag = false )
{
$this->_flag = ( boolean ) $flag ;
.button a {
/* text-style */
font-size: 12px;
color: #03c;
text-align: center;
text-decoration: none;
line-height: 100%;
/* block-style */
display: block;
<?php
require_once 'Zend/View/Helper/Abstract.php';
class Juke_View_Helper_Request extends Zend_View_Helper_Abstract
{
public function request()
{
return $this ;
}
public function __call( $method, $args )
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>test</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery", "1.4");</script>
<script type="text/javascript" src="jquery.accordion_tree.js"></script>
</head>
<body>
<?php
class Koshian_File implements Iterator
{
private $_lines = array();
private $_index = 0;
public function __construct( $file, $flag = 0 )
{
if( file_exists( $file ) && is_readable( $file ) ) {
$this->_lines = file( $file, $flag ) ;
<?php
// 「a」という箱に「あ」が入ってる
$array['a'] = 'あ' ;
// 「b」という箱に「い」が入ってる
$array['b'] = 'い' ;
// 「c」という箱に「う」が入ってる
$array['c'] = 'う' ;
// 「い」 を表示したい時は「b」という箱を参照してやる
echo $array['b'] ;
@koshiaaaaan
koshiaaaaan / switch_true.php
Created November 2, 2010 08:00
switch( true ) のやつ
<?php
$a = 1 ;
switch( true ) {
case ( is_string( $a ) ) :
echo '$a は 文字列' ;
break ;
case ( is_integer( $a ) ) :
echo '$a は 数値' ;
break ;
@koshiaaaaan
koshiaaaaan / feed_cache_test.php
Created November 9, 2010 04:30
feedのキャッシュ
<?php
$cache_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'cache' ;
if( realpath( $cache_dir ) === false ) {
if( ! mkdir( $cache_dir, 0777 ) ) {
exit( 'Error!' ) ;
}
}
$cache_dir = realpath( $cache_dir ) ;
@koshiaaaaan
koshiaaaaan / db.php
Created December 23, 2010 02:25
複数コネクションを持つ場合。こんな感じかなぁ・・・
<?php
class DB{
var $db_encoding="UTF-8";
var $script_encoding="UTF-8";
var $db=null;
#---------------------------
# constructer
#---------------------------
function DB($db=DBNAME,$user=USER,$pass=PASS,$host=HOST){