我有一個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>";
}
}
?>
我也想知道是否在第二個代碼中成功實現了與其他文件的鏈接?我的意思是,鏈接和腳本標籤在上面。
你檢查HTML源代碼?可能有些東西沒有顯示出來,因爲你在一個表格行裏... – Franz 2009-11-13 11:08:11
你的代碼很混亂。你至少應該把類和標記分開。包括cookie處理腳本和在錶行中間使用鏈接標記也不是一個好主意......如果您完全刪除了該類幷包含普通的PHP代碼,那麼您真的會變得更好...... – Palantir 2009-11-13 11:10:13