にファイルをインクルードします。私は唯一のケースを書いたが、20以上のcases.owがあり、私はoutput..hereを示すためのindex.php内の別のファイルが含まれない私のコードです:ここは、どのように私は、私は2つのファイルを持っている私のindex.php
//index.php
<?
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=dhaka');
$information = $xml->xpath("/xml_api_reply/weather/forecast_information");
$current = $xml->xpath("/xml_api_reply/weather/current_conditions");
$forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions");
?>
<html>
<head>
<title>Google Weather API</title>
</head>
<body>
<h1><?= print $information[0]->city['data']; ?></h1>
<h2>Today's weather</h2>
<div class="weather">
<?php
include 'condition.php';
?>
<span class="condition">
<?= $current[0]->temp_f['data'] ?>° F,
<?= $current[0]->condition['data'] ?>
</span>
</div>
</body>
</html>
はcondition.phpある
switch ($cond)
{
case "Mostly Cloudy":
$col="/test/images/weather/mostly_cloudy.png";
echo "<img src=\"$col\" alt=\"\"/>";
break;
case "Thunderstorm":
$col="/test/images/weather/thunderstorm.png";
echo "<img src=\"$col\" alt=\"\"/>";
break;}
私は2件を投稿しましたが、20件以上があります。
何が問題なのですか?それは正しいようです。 – Jules
$ condはどこに定義されていますか? index.phpのどこにも定義されていない場合は、どこでもcondition.phpに定義されず、 'default'の場合以外は一致しません。つまり出力されません。 –
$ condはindex.php.typing mistakeで定義されています – Adnan