php什么都加载不了
1个回答
展开全部
common.php
<?php
public static function readTabFile($fileName)
{
if (!file_exists($fileName))
{
die("<b>404 File not found!</b>");
}
$handle = fopen($fileName, 'rb');
$contents = fread($handle, filesize ($fileName));
//iconv("UTF-8","GBK", $contents);
if(ord($contents) == 0xEF)
{
$contents = substr($contents, 4);
}
$rows = explode("\r\n", $contents);
fclose($handle);
$ret;
$colNames = null;
for($i = 0; $i < count($rows); $i++)
{
$row = $rows[$i];
if(!empty($row) && $row != "" && substr($row, 0, 1) != "#")
{
$col = explode("\t", $row);
if(empty($colNames) || $colNames == null)
$colNames = $col;
else
{
$item;
$itemId = (int)$col[0];
if(empty($itemId))
{
die("...");
}
for($j = 0; $j < count($col); $j++)
{
$value = $col[$j];
$item[$colNames[$j]] = $value;
}
$ret[$itemId] = $item;
}
}
}
return $ret;
}
?>
test.php
<?php
$dir = "../goods.tab";
$table = Common::readTabFile($dir);
?>
<script>
var goodsTb = new Array();
<?php
foreach($table as $key => $value)
{
echo "goodsTb[".$value["id"]."]=\"".iconv("GBK","UTF-8", $value["sz_name"])."\";";
}
?>
function checkNum(i)
{
var sle_obj = document.getElementById('valueType' + i);
var index = sle_obj.selectedIndex;
var valueType = sle_obj.options[index].value;
var num_obj = document.getElementById('count' + i);
if(valueType == -1)
{
alert('请选择道具类型!');
}
if(num_obj.value > 500)
num_obj.value = 500;
}
var i = 1;
function addFile()
{
var dv = document.getElementById("dvFiles");
var selectObj = document.createElement("select");
selectObj.name = "valueType";
selectObj.id = "valueType" + i;
var sg = document.createTextNode("选择道具 ");
dv.appendChild(sg);
//创建select选项卡
var myOption = document.createElement("option");
myOption.setAttribute("value","-1");
myOption.appendChild(document.createTextNode("无"));
selectObj.appendChild(myOption);
for (var key in goodsTb)
{
var op = document.createElement("option");
op.setAttribute("value", key);
op.appendChild(document.createTextNode(goodsTb[key]));
selectObj.appendChild(op);
}
dv.appendChild(selectObj);
....
附上出处链接:http://bbs.csdn.net/topics/390522693?page=1
<?php
public static function readTabFile($fileName)
{
if (!file_exists($fileName))
{
die("<b>404 File not found!</b>");
}
$handle = fopen($fileName, 'rb');
$contents = fread($handle, filesize ($fileName));
//iconv("UTF-8","GBK", $contents);
if(ord($contents) == 0xEF)
{
$contents = substr($contents, 4);
}
$rows = explode("\r\n", $contents);
fclose($handle);
$ret;
$colNames = null;
for($i = 0; $i < count($rows); $i++)
{
$row = $rows[$i];
if(!empty($row) && $row != "" && substr($row, 0, 1) != "#")
{
$col = explode("\t", $row);
if(empty($colNames) || $colNames == null)
$colNames = $col;
else
{
$item;
$itemId = (int)$col[0];
if(empty($itemId))
{
die("...");
}
for($j = 0; $j < count($col); $j++)
{
$value = $col[$j];
$item[$colNames[$j]] = $value;
}
$ret[$itemId] = $item;
}
}
}
return $ret;
}
?>
test.php
<?php
$dir = "../goods.tab";
$table = Common::readTabFile($dir);
?>
<script>
var goodsTb = new Array();
<?php
foreach($table as $key => $value)
{
echo "goodsTb[".$value["id"]."]=\"".iconv("GBK","UTF-8", $value["sz_name"])."\";";
}
?>
function checkNum(i)
{
var sle_obj = document.getElementById('valueType' + i);
var index = sle_obj.selectedIndex;
var valueType = sle_obj.options[index].value;
var num_obj = document.getElementById('count' + i);
if(valueType == -1)
{
alert('请选择道具类型!');
}
if(num_obj.value > 500)
num_obj.value = 500;
}
var i = 1;
function addFile()
{
var dv = document.getElementById("dvFiles");
var selectObj = document.createElement("select");
selectObj.name = "valueType";
selectObj.id = "valueType" + i;
var sg = document.createTextNode("选择道具 ");
dv.appendChild(sg);
//创建select选项卡
var myOption = document.createElement("option");
myOption.setAttribute("value","-1");
myOption.appendChild(document.createTextNode("无"));
selectObj.appendChild(myOption);
for (var key in goodsTb)
{
var op = document.createElement("option");
op.setAttribute("value", key);
op.appendChild(document.createTextNode(goodsTb[key]));
selectObj.appendChild(op);
}
dv.appendChild(selectObj);
....
附上出处链接:http://bbs.csdn.net/topics/390522693?page=1
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询