我还有一个带有HTML代码的.php文件。通过这个文件,我在一个驻留在类中的另一个.php文件中调用一个函数。通话无效。它根本就没有在课堂上输入这个功能。
以下是第一档和第二档的代码。
<div id="sectionGrid"> <!-- Begin of Grid Section -->
<table id="tblGrid">
<tr>
<?php
require("../Lib/displaygrid.php");
displaygrid::SetGridWithValues("*","electioncategorymaster");
?>
</tr>
</table>
</div> <!-- End of Grid Section -->
上面只是第一个文件的一部分。下面是第二个文件整个代码:
<script type="text/javascript" src="js_cookiefunctions.js"/>
<link rel="stylesheet" href="DGStyle.css" type="text/css">
<?php
final class displaygrid
{
public static function SetGridWithValues($columnNames,$tableName)
{
echo $columnNames;
require 'obfusGrid.php';
require 'obfusGridSqlDAP.php';
require("../Config/dbconfig.php");
// Load the database adapter
$db = new MySQLAdap(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
// Load the datagrid class
$x = new MyDataGrid($db);
// Set the query
$x->setQuery($columnNames, $tableName);
// Add a row selector
$x->addRowSelect("SetRowInCookie(%ID%);");
echo $columnNames;
// Apply a function to a row
function returnSomething($ID)
{
return strrev($id);
}
$x->setColumnType('ID', MyDataGrid::TYPE_FUNCTION, 'returnSomething', '%id%');
// Print the table
$x->printTable();
//Show button to return to keywords entry page
echo "<br><input id='backbutton' type='button' value='Back' onclick='ReturnBack()';>";
echo "<script type='text/javascript'>alert(cookie['row_id']);</script>";
}
}
?>
我还想知道在第二个代码中是否成功实现了到其他文件的链接?我的意思是,链接和脚本标签位于顶部。
答案 0 :(得分:3)
我认为您有PHP错误。请打开error_reporting。你能尝试删除这个文件顶部的两行../ Lib / displaygrid.php
<script type="text/javascript" src="js_cookiefunctions.js"/>
<link rel="stylesheet" href="DGStyle.css" type="text/css">
希望这有帮助!但请打开错误报告以查看实际错误的位置。
答案 1 :(得分:1)
包含路径可能有问题吗?
尝试:
require dirname(__FILE__) . '/../Lib/path/to/required.file.php';
答案 2 :(得分:1)
使用ini_set( 'display_errors', 1 )
和error_reporting ( E_ALL )
答案 3 :(得分:1)
您必须删除前两行文件../Lib/displaygrid.php才能使代码生效。
<script type="text/javascript" src="js_cookiefunctions.js"/>
<link rel="stylesheet" href="DGStyle.css" type="text/css">
顺便说一句,你应该编写更清晰的代码,避免将演示与代码混合