ラベル PHP の投稿を表示しています。 すべての投稿を表示
ラベル PHP の投稿を表示しています。 すべての投稿を表示

2008年6月19日木曜日

p.130 PHP

utano

p.130のPHPコードです。
ウェブのテキストだけ抽出する(HTMLタグどける)ものです。
こんなかんじ。

/* AIRNow Web Page Scraper
Language: PHP
*/

$readParticles = 0; //flag telling you the next time is the particle value
$particles = -1;

//Define variables
//url of the page with the air quality index data for New York City
$url = 'http://airnow.gov/index.cfm?action=airnow.showlocal&CityID=164';

//open the file at the url for reading;
$filePath = fopen($url, "r");

//as long as you haven't reached the end of the file:
while(!feof($filePath)){
//read one line at a time, and strip all HTML and PHP tags from the line
$line = fgetss($filePath, 4096);
echo $line;
}
//close the file at the URL , you're done
fclose($filePath);
?>


p.131と合体させたもの。
これはテキスト化したウェブから、
ある文字列が出たあとの後ろのテキストを抽出するコード。
こんなかんじ。

/* AIRNow Web Page Scraper
Language: PHP
*/

$readParticles = 0; //flag telling you the next time is the particle value
$particles = -1;

//Define variables
//url of the page with the air quality index data for New York City
$url = 'http://airnow.gov/index.cfm?action=airnow.showlocal&CityID=164';

//open the file at the url for reading;
$filePath = fopen($url, "r");

//as long as you haven't reached the end of the file:
while(!feof($filePath)){
//read one line at a time, and strip all HTML and PHP tags from the line
$line = fgetss($filePath, 4096);

if($readParticles == 1){
$particles = trim($line);
echo "";
$readParticles = 0;
}

if(preg_match('/AQI observed at /', $line)){
if($particles == -1){
$readParticles = 1;
}
}

}
//close the file at the URL , you're done
fclose($filePath);
?>

2008年6月10日火曜日

初めてのPHP

一応P91の下のプログラムができたっぽいです。

プログラムによるとif文の判定から僕はまだお酒を飲んではいけないらしいのですが
どの値から結果を出しているのですかね?

あとP90の下にあるプログラムもよく分からないです。
こんな感じです。

あとコマンドライン(putty?)関係が一切分かりません。
英文をしっかり読まないといけないみたいです、頑張ります。

2008年6月6日金曜日

PHP

utano

ワタシの課題:
p.30-31のcommand lineはやっぱりわからん
p.92-93でtelnet smtp.example.com 25で接続エラー出る

ソースコードを貼り付けようとしたのですが
HTMLを含んでいるのでエラーが出てしまい貼れませんでした。

では寝ます。

2008年6月5日木曜日

phpについて

utano

作業が遅いです、すみません。

一つ提案ですがこれから進行にズレが生じてくると思うので
投稿した記事のタグにchapter3など章のタグを付けませんか??

今PuTTYを使ってcommand lineに書き込んだりしています。

p.89終わりにChapter1で書いたPHPを
command lineから呼び出そうという所で戸惑っています。

p.30-31を見ながらPHPファイルを作って
学校アカウントのpublic_htmlディレクトリに上げました。

php hello.php
で本来command lineからファイルを呼び寄せる事が出来るのですが
php: Command not found.
といわれます。

さかのぼってPHPのバージョンを調べるために
php -vを入力しても同じ結果が出ました。

????

ちなみにウェブブラウザからは確認が出来ました

今日はここまで。明日とりあえずすっ飛ばして(いけるのか?)先を見ます。