我是否必须在移动设备上使用不同的PHP?

时间:2014-03-06 02:15:32

标签: php html

这是我的第一个基于PHP的Web项目。我有它的网络部分工作完美,但我有移动版本的问题。 (Godaddy linux上的虚拟主机)

我的.php页面无法显示的原因是什么?如果我将其更改为.html,它可以正常工作。 (我怀疑是doctype,但不确定。) 不确定这段代码是否必要,但为了空间我会遗漏身体:

<?php include_once 'web/config.php'?>
<!DOCTYPE HTML>
<html>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>About - Mobile</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="keywords" content="About - Mobile" />
<link href="css/style.css" rel="stylesheet" type="text/css"  media="all" />
</head>

的config.php:

$link = mysqli_connect($server, $db_user, $db_pass);
mysqli_select_db($link, $database);

// -=-=-=-=-=-=-=[ Getting Variables ]=-=-=-=-=-=-=- //
$query = "SELECT * FROM `misc`";
$result = $link->query($query);
while($info = mysqli_fetch_array($result)){
// -=-=-=-=-=-=-=[ Variables ]=-=-=-=-=-=-=- //
$pickupTime = $info['pickupTime'];
$deliveryTime = $info['deliveryTime'];
$minDeliveryPrice = $info['minDeliveryPrice'];
$Gtitle = $info['Gtitle'];
$emailAccount = $info['emailAccount'];
$phone = $info['phone'];
$mailSubject= $info['mailSubject'];
$address = $info['address'];
$city = $info['city'];
$zipcode = $info['zipcode'];
$companyTel = $info['companyTel'];
$companyEmail = $info["companyEmail"];
$facebookLink = $info['facebookLink'];
$twitterLink = $info['twitterLink'];
$googleLink = $info['googleLink'];
$termsOfService = $info['termsOfService'];
}
?>

提前致谢!

3 个答案:

答案 0 :(得分:3)

PHP在服务器端执行,只要PHP脚本呈现有效的HTML(但这似乎不是这种情况),手机将无关紧要。

如果浏览器接收到PHP代码,则服务器出现问题(例如,您没有在服务器端安装PHP,或者Web服务器不知道何时调用PHP来生成网页)

浏览器永远不会收到PHP代码(否则很容易劫持数据库,因为PHP代码有某种程度的密码)。

答案 1 :(得分:1)

PHP在服务器上执行,客户端不知道它正在与PHP通信。在定位移动平台时,您无需更改PHP代码。

您的问题似乎是损坏的HTML

<?php include_once 'web/config.php'?>

我们应该看到config.php文件,看看那里发生了什么。

<!DOCTYPE HTML>
<html>

在这里打开<HTML>标记。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

在这里打开另一个<HTML>标记,这是一个问题。您应该只有一个<HTML>标记作为文档中的外部节点。

<head>
<title>About - Mobile</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="keywords" content="About - Mobile" />
<link href="css/style.css" rel="stylesheet" type="text/css"  media="all" />
</head>

您没有关闭<HTML>代码,也没有要渲染的正文。

答案 2 :(得分:1)

好吧,因为你说你只贴了头。我只是要修复你的HTML至少让它有效。关于php,其他答案解释了为什么php在浏览器中查看网站无关紧要

<?php include_once 'web/config.php'?>
<!DOCTYPE HTML>
<html>
    <head>
        <title>About - Mobile</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="keywords" content="About - Mobile" />
        <link href="css/style.css" rel="stylesheet" type="text/css"  media="all" />
    </head>
    <body>
    ....
    </body>
</html>

如果这不起作用,那么我猜这行php <?php include_once 'web/config.php'?>正在输出搞乱html的东西,换句话说,使它无效,所以尝试删除它然后尝试< br />
你的意思是什么呢?什么都没有出现?或者是否会产生(http和/或php)错误?