Apache处理我的PHP文件,但显示"?>"在开始时

时间:2016-05-20 18:57:08

标签: php apache

关于在本地计算机上运行的Apache Server,我遇到了问题。直到昨天一切都很好,但今天它没有正确处理我的.php文件:当页面显示时,它们都显示了php的结束括号,拧紧了我所有基于客户端的应用程序。 这是一个.php文件示例。他们现在都遇到了同样的问题。

<?php
/*
 * Following code will list all the products
 */

// array for JSON response
$response = array();

// include db connect class
require_once __DIR__ . '/db_connect.php';


// connecting to db
$db = new DB_CONNECT();

$unidad = $_GET['unidad'];
// get all products from products table
$result = mysql_query("SELECT a.unidad, a.tpo_med, a.num_med, a.consumo, a.fec_med, a.est_med, b.razon FROM gmest_med a, gcunidad b WHERE a.unidad='$unidad' AND a.unidad=b.unidad ORDER BY fec_med DESC LIMIT 0,1") or die(mysql_error());



// check for empty result
if (mysql_num_rows($result) > 0) {
    // looping through all results
    // products node
    $response["medidor"] = array();

    while ($row = mysql_fetch_array($result)) {
        // temp user array
        $product = array();
        $product["unidad"] = $row["unidad"];
        $product["tpo_med"] = $row["tpo_med"];
        $product["num_med"] = $row["num_med"];
        $product["fec_med"] = $row["fec_med"];


$product["est_med"] = $row["est_med"];
    $product["consumo"] = $row["consumo"];
    $product["razon"] = $row["razon"];

    // push single product into final response array
    array_push($response["medidor"], $product);
}
// success
$response["success"] = 1;

// echoing JSON response
echo json_encode($response);
} else {
    // no products found
    $response["success"] = 0;
    $response["message"] = "No products found";

    // echo no users JSON
    echo json_encode($response);
}
?>

这将显示以下JSON(例如):

?>{"medidor":[{"unidad":"410020","tpo_med":"ACT1","num_med":"A06S831658","fec_med":"2015-10-13 00:00:00","est_med":"3309","consumo":"31","razon":"ARIAS, HUMBERTO C"}],"success":1}

0 个答案:

没有答案