memo.xight.org

Home > Changelogメモ > PHP > 8ページ目 (全9ページ)
ChangeLog 最新ページ / カテゴリ最新ページ / 前ページ 1 2 3 4 5 6 7 8 9 次ページ / 8ページ目 (全9ページ)
2008-12 / 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

2004-05-10 Mon

JpGraph

- Summary

JpGraph is an OO class library for PHP >=4.2.0.
The only other hard requirement is that the PHP installation suppports the GD library which most modern PHP installations do.

- Reference
  JpGraph - OO Graph Library for PHP
  http://www.aditus.nu/jpgraph/

カテゴリ: [PHP][視覚化]
内部リンク: [2005-07-19-9]

2004-02-16 Mon

XML_RSS

- XML_RSSパッケージのインストール

# pear install xml_rss


- サンプル

<?php
	require_once("XML/RSS.php");
	$rss =& new XML_RSS("http://www.pat.hi-ho.ne.jp/dimension/home.rss");
	$rss->parse();
	echo "<ul>\n";
	foreach ($rss->getItems() as $item) {
		echo "<li><a href=\"" . $item['link'] . "\">" .
		mb_convert_encoding($item['title'],
		mb_internal_encoding(), 'auto') .
		"</a></li>\n";
	}
	echo "</ul>\n";
?>


- Reference
XML_RSS

  Do You PHP? - PEARのXML_RSSでRSSしてみる
  http://www.pat.hi-ho.ne.jp/dimension/sample/sample_xml_pear_rss.shtml

カテゴリ: [PHP][RSS]

2004-02-16 Mon

MagpieRSS

- Summary
  PHPで使えるRSSパーサー
- サンプル

<?php
	require_once 'rss_fetch.inc';
	$url = 'http://www.hyuki.com/yukiwiki/wiki.cgi?RssPage';
	$rss = fetch_rss($url);
	$title = $rss->channel['title'];
	$title = mb_convert_encoding($title, "SJIS", "auto");
	echo "<h2>$title</h2>\n";
	echo "<ul>\n";
	foreach ($rss->items as $item ) {
		$title = $item[title];
		$title = mb_convert_encoding($title, "SJIS", "auto");
		$url   = $item[link];
		echo "<li><a href=\"$url\">$title</a></li>\n";
	}
	echo "</ul>\n";
?>

- Reference
  YukiWiki - MagpieRSS
  http://www.hyuki.com/yukiwiki/wiki.cgi?MagpieRSS

カテゴリ: [PHP][RSS]

2004-01-20 Tue

VimでPHP関数の辞書を作成する方法

- vim.sourceforge.net から PHP.dictを取得
  $HOME/.vim/PHP.dict に保存
- .vimrc に以下を記述

autocmd FileType php  :set dictionary=$HOME/.vim/PHP.dict


- 方法

Ctrl-x Ctrl-k

- Reference
  Vim で PHP 関数の辞書を作成する方法についてのメモ
  http://www.asahi-net.or.jp/~wv7y-kmr/memo/vim_php.html
  PHP-dictionary - A PHP-dictionary as a building stone for scripts : vim online
  http://vim.sourceforge.net/scripts/script.php?script_id=534

カテゴリ: [PHP][vim]

2004-01-12 Mon

多次元配列のソート

- Sample

$Array = array($file[0] => array("filename","date","filesize"));
usort($Array , "cmp");
function cmp($a , $b){
	return strcmp($a[0] ,$b[0] ); // <--- ここのaとbの入れ替えで昇順,降順を決められる
}

- Reference
  PHPメモ
  http://tsmith.hp.infoseek.co.jp/program/php.html

カテゴリ: [PHP]

2004-01-10 Sat

CSV形式でのデータのダウンロード

- 方法
  1. サーバ側でCSVファイルを作成し,ダウンロードさせる
  2. Header関数でContent-typeを出力し,整形したデータをそのまま返す
- サンプル

/* HTTPヘッダの出力 */
Header("Content-disposition: attachment; filename=test.csv");
Header("Content-type: application/octet-stream; name=test.csv");
/* データを出力 */
echo $contents;

- Reference
  Do You PHP? - CSV形式でのデータダウンロード
  http://www.pat.hi-ho.ne.jp/dimension/sample/sample_ora_csv.shtml

カテゴリ: [PHP]

2004-01-10 Sat

日付操作処理の関数

- Program Rabo提供の date.php
  ----年--月--日の--日後を計算可能
- Reference
  Program Rabo - PHPプログラム - 日付操作処理
  http://www.spicy-islands.com/php/date/

カテゴリ: [PHP]

2004-01-06 Tue

連想配列をPush

- こんな方法もある
  $arr = array();
  $arr += array("0" => "apple");
  $arr += array("1" => "orange");
- Reference
  PHP-users ML - [PHP-users 13781] Re: array_pushで連想配列
  http://ns1.php.gr.jp/pipermail/php-users/2003-March/014313.html

カテゴリ: [PHP]

2003-11-26 Wed

連想配列の走査

- 例

$a = array(
	"one"	 => 1,
	"two"	 => 2,
	"three" => 3,
);
foreach ($a as $k => $v){
	echo "\$a[$k] => $v\n";";
}

- 出力例

$a[one] => 1
$a[two] => 2
$a[three] => 3


- 一言
  Debug時の $_SESSION の dump に利用

カテゴリ: [PHP]

2003-11-23 Sun

セッション管理

- 値の渡し方
  $_SESSION['idx'] = $idx;
  <form action="somewhere.php?"> // セッションID 管理
- 方法
  // セッションを開始/復元
  session_start();
  // セッション変数登録
  session_register(idx);
  $_SESSION['idx'] で取り出せる.
- Reference
  PHP 基礎編6 - 数値関数、その他
  rand、floor、ceil、round、$REMOTE_ADDR - SAK Streets
  http://homepage2.nifty.com/sak/w_sak3/doc/sysbrd/php_k06.htm

カテゴリ: [PHP]

2003-11-05 Wed

エラーが出てもエラー表示させない

- 方法

<?php
	$size = @GetImageSize("img/flag.jpg");
?>


  関数の前に`@'をつける

- Reference
  PHP Manual - エラー制御演算子

カテゴリ: [PHP]

2003-11-05 Wed

画像からメタ情報を取得

- 方法

<?php
	$size = GetImageSize("img/flag.jpg");
?>
<img src="img/flag.jpg" <?php echo $size[3]; ?> />


- $size[3] の中身
width="120" height="40"

- つまり
<img src="img/flag.jpg" width="120" height="40" />

カテゴリ: [PHP]

2003-11-05 Wed

Magpie RSS - PHP RSS Parser

- Summary
  PHPでRSSを扱うためのParser

- Reference
  Magpie RSS - PHP RSS Parser
  http://magpierss.sourceforge.net/

カテゴリ: [PHP]

2003-11-01 Sat

連想配列をキーでソートして走査

- サンプル

$fruits = array (
	"d"=>"lemon",
	"a"=>"orange",
	"b"=>"banana",
	"c"=>"apple"'
);
ksort ($fruits);
reset ($fruits);
while (list ($key, $val) = each ($fruits)) {
	echo "$key = $val\n";
}

- 出力

a = orange
b = banana
c = apple
d = lemon


- Reference
PHP Manual - ksort

カテゴリ: [PHP]

2003-10-23 Thu

定数の使用法

- 定義方法
  define('NUM',12345); // 整数,浮動小数点の定義
  define('NKF_PATH','/usr/bin/nkf'); // 文字型の定義

- 使用上の注意 - echo
  ×

echo "nkfへのパスは = NKF_PATH";   // nkfへのパスは = NKF_PATH

  ○
echo "nkfへのパスは = ".NKF_PATH;  // nkfへのパスは = /usr/bin/nkf


- 使用上の注意 - exec
  ×
exec("NKF_PATH NKF_OPTION $import_file > $import_file_euc");

  ○
exec(NKF_PATH." ".NKF_OPTION." $import_file > $import_file_euc");

カテゴリ: [PHP]

2003-10-20 Mon

mb_ereg の未定義エラー

- phpinfoを見ても
  --enable-mbstring 付き
  Multibyte (Japanese) Support もOK
- 原因
  --enable-mbregex 付きで configure されていない.
- 詳細
  --enable-mbstring
    mb_strlen()
    mb_strpos()
    mb_strrpos
    mb_substr()
  --enable-mbregex
    mb_ereg()
    mb_eregi()
    mb_ereg_replace()
    mb_eregi_replace()
    mb_split
- 現行の PHP4.3.3-1 の Debianパッケージのマルチバイト対応状況
  --enable-mbstring のみ付いている為,mb_str* しか使用できない.
  --enable-mbregex 付きで再コンパイルするしかない.
- Reference
  [PHP-users 13906] Re: マルチバイト対応:mb_eregの未定義エラーについて
  http://ns1.php.gr.jp/pipermail/php-users/2003-March/014438.html

カテゴリ: [PHP][Debian][Trouble Shooting]

2003-09-21 Sun

PHP の mysql_connect() で Call to undefined function

- Summary
Call to undefined function: mysql_connect()
というエラーが発生する.

- 原因
/etc/php/apache/php.ini

;extension=mysql.so


extension=mysql.so が コメントアウトされていた.

- 対処法
  /etc/php/apache/php.ini を

extension=mysql.so


  と変更して

# apachectl stop
# apachectl start

  で apache 再起動

カテゴリ: [PHP][MySQL][Trouble Shooting]

2003-09-08 Mon

input type="checkbox"

- ダメサンプル

<form method="GET" action="region.php">
	<input type="checkbox" name="region_code" value="01" />
	<input type="checkbox" name="region_code" value="02" />
	<input type="checkbox" name="region_code" value="03" />
</form>

- $region_code という配列に入って欲しいのに入らない.
  最後の値が上書きされる.

- 良いサンプル
<form method="GET" action="region.php">
	<input type="checkbox" name="region_code[]" value="01" />
	<input type="checkbox" name="region_code[]" value="02" />
	<input type="checkbox" name="region_code[]" value="03" />
</form>

- $region_code という配列に入ってくれる.
  name="hoge[]"
  がミソ
- Reference
  [PHP-jp 2755] Re: Form のCHECKBOXの値について
  http://www.nishimoto-site.net/archiver/ML/php-ML/199912/msg00134.html

カテゴリ: [PHP]
2008-12 / 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
最終更新時間: 2008-12-02 10:52

Color Reference

ChangeLogを検索
携帯電話からアクセス!

カテゴリ

最近の話題

リンク

過去ログ

Google

QR Code

Since
2002-11-28
Update
2008-12-02 10:52
Copyright © 2005 xight.org All Rights Reserved.