php - 我在回显的 switch 语句中的变量的 PHP '注意:未定义变量'错误
问题描述
我的 PHP 中有这个错误,我似乎不明白为什么:
注意:未定义变量:第 12 行 C:\xampp\htdocs\ws5\process.php 中的站点
我似乎在我的 switch 语句中回显的每个变量都得到了它
我的代码是:
<?php
$horfield = file_get_contents("http://www.martynhicks.uk/weather/clientraw.txt");
$thornbury = file_get_contents("http://www.thornburyweather.co.uk/weatherstation/clientraw.txt");
$gloucestershire = file_get_contents("https://www.glosweather.com/clientraw.txt");
$newquay = file_get_contents("http://www.newquayweather.com/clientraw.txt");
if (isset($_GET['site'])){
$site = $_GET['site'];
}
switch ($site) {
case 'Horfield':
echo $horfield;
break;
case 'Thornbury':
echo $thornbury;
break;
case 'Glouc':
echo $gloucestershire;
break;
case 'Newquay':
echo $newquay;
break;
}
?>
(第 12 行是第一个 echo 语句 'echo $horfield',其他 3 行也是如此。]
谢谢
解决方案
推荐阅读
- mysql - 从视图中选择 * 比直接使用 MySQL 5.7 执行视图创建语句慢 10 倍以上
- android - React native 和 native 可以同时访问的存储?
- javascript - ReferenceError:页面刷新后未定义google
- c# - 正则表达式匹配由许多零或空格进行的 1 到 4 位数字
- c++ - 是什么导致“OpenCV(4.0.1)错误:断言失败(m.dims <= 2)”
- tinyos - TinyOS中基本代码的含义是什么
- jquery - 如何使 jQuery AutoComplete 功能在 Durandal 中工作?
- odata - ODATA:“或”运算符的问题
- c++ - Web 服务器如何知道 HTTP 请求何时被完全接收?
- haskell - Haskell:从多个可能中生成一个数组