我有一个在线站点可以使用具有 php 和 mysql 的“000webhost.com”进行测试和编辑。
要么 javascript 没有提取 PHP 变量,要么站点没有加载 php。
当我加载页面时,我启动 chrome 代码查看器来实时检查代码。查看 default.php (索引页)时,它没有显示我的 php 变量。
Javascript
window.onload = function(){
var iso = "<?= $isop; ?>";
var meg = "<?= $megp; ?>";
var mex = "<?= $mexp; ?>";
var mor = "<?= $morp; ?>";
var noc = "<?= $nocp; ?>";
var pye = "<?= $pyep; ?>";
var tri = "<?= $trip; ?>";
var zyd = "<?= $zydp; ?>";
}
页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Str8nge Brew Calculator</title>
</head>
<body>
<?php
$isop = "1";
$megp = "1";
$mexp = "1";
$morp = "1";
$nocp = "1";
$pyep = "1";
$trip = "1";
$zydp = "1";
?>
<script type="text/javascript" src="calceve.js"></script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
....
</body>