対象の phpファイルの先頭と最後が、PHP コード用のタグであるという前提です。 グルーバル変数にテキストをセットして、eval する事によって、グローバルスコープ で実行したのと同じ事になります http://lightbox.in.coocan.jp/gen/db.txt 拡張子:txtvbswsfjsphpjavahtmlutf8sjis <? function inc( $path ) { $inc = @file( $path ); array_shift($inc); array_pop($inc); $GLOBALS['inc_eval_txt'] = implode( "", $inc ); eval($GLOBALS['inc_eval_txt']); } $conf_client_charset = "euc-jp"; header( "Content-Type: text/html; Charset=$conf_client_charset" ); header( "Expires: Wed, 31 May 2000 14:59:58 GMT" ); # ********************************************************** # 外部ファイル # ********************************************************** $conf_db_type = 1; inc( "http://lightbox.in.coocan.jp/gen/db.txt" ); # ********************************************************** # 接続 # ********************************************************** $SQL = new DB( "********", "********", "********", "********" ); $Query = "select 内容 from ora_問題 where 問題ID between 210 and 220 order by 問題ID"; $Column = $SQL->QueryEx( $Query ); $GLOBALS['qdata'] = ""; while( $Column ) { $GLOBALS['qdata'] .= "<TR><TD>{$Column['内容']}</TD></TR>\n"; $Column = $SQL->QueryEx( ); } # ********************************************************** # 接続解除 # ********************************************************** $SQL->Close(); ?> <HTML> <HEAD> <META http-equiv="Content-type" content="text/html; charset=<?= $conf_client_charset ?>"> <TITLE>HTML テンプレート</TITLE> <STYLE type="text/css"> * { font-family: "MS Pゴシック"; font-size: 12px; } </STYLE> </HEAD> <BODY> <TABLE border="1" cellpadding="5"> <?= $GLOBALS['qdata'] ?> </TABLE> </BODY> </HTML>
<? function inc( $path ) { $inc = @file( $path ); array_shift($inc); array_pop($inc); $GLOBALS['inc_eval_txt'] = implode( "", $inc ); eval($GLOBALS['inc_eval_txt']); } $conf_client_charset = "euc-jp"; header( "Content-Type: text/html; Charset=$conf_client_charset" ); header( "Expires: Wed, 31 May 2000 14:59:58 GMT" ); # ********************************************************** # 外部ファイル # ********************************************************** $conf_db_type = 1; inc( "http://lightbox.in.coocan.jp/gen/db.txt" ); # ********************************************************** # 接続 # ********************************************************** $SQL = new DB( "********", "********", "********", "********" ); $Query = "select 内容 from ora_問題 where 問題ID between 210 and 220 order by 問題ID"; $Column = $SQL->QueryEx( $Query ); $GLOBALS['qdata'] = ""; while( $Column ) { $GLOBALS['qdata'] .= "<TR><TD>{$Column['内容']}</TD></TR>\n"; $Column = $SQL->QueryEx( ); } # ********************************************************** # 接続解除 # ********************************************************** $SQL->Close(); ?> <HTML> <HEAD> <META http-equiv="Content-type" content="text/html; charset=<?= $conf_client_charset ?>"> <TITLE>HTML テンプレート</TITLE> <STYLE type="text/css"> * { font-family: "MS Pゴシック"; font-size: 12px; } </STYLE> </HEAD> <BODY> <TABLE border="1" cellpadding="5"> <?= $GLOBALS['qdata'] ?> </TABLE> </BODY> </HTML>