티스토리 뷰
script 를 삽입한 구문에 js 출력 하여 윗젯을 구현 한다. ~
* Html
* Php
header('Content-type: application/javascript');
require 'weather.php'; // Load supporting code
$zip = ( isset($_GET['zip']) ) ? $_GET['zip'] : "";
$weather = getWeatherData($zip);
$location = $weather['location'];
$temperature = $weather['temperature'];
$desc = $weather['desc'];
// Must qualify full path for asset urls; relative
// urls won't work, as they'll point to the publisher's server
$image = preg_replace('/[^\/]+$/', '', $_SERVER['REQUEST_URI']) . $weather['image'];
// Output JavaScript to page
echo <<
\
$location
\
\
$temperature °F — $desc
\
');
EOD;
'웹개발 > Javascript' 카테고리의 다른 글
| Command 패턴 정리 (0) | 2011.10.18 |
|---|---|
| Javascript Observer Pattern (0) | 2011.09.30 |
| 정규표현식 정후방 탐색 (0) | 2011.07.18 |
| Javascript 클로저 ~ 예시 (0) | 2011.01.12 |
| 알면 좋은 자바스크립트 간단한 팁, (0) | 2011.01.08 |
댓글