[英]A public static function in a class not executing
我也有一個帶有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>";
}
}
?>
我還想知道在第二個代碼中是否成功實現了到其他文件的鏈接? 我的意思是,鏈接和腳本標簽位於頂部。
我認為您有PHP錯誤。 請打開error_reporting。 您可以嘗試刪除此文件頂部的兩行嗎?./Lib/displaygrid.php
<script type="text/javascript" src="js_cookiefunctions.js"/>
<link rel="stylesheet" href="DGStyle.css" type="text/css">
希望這可以幫助! 但是打開錯誤報告以查看實際錯誤在哪里。
也許包含路徑有問題?
嘗試:
require dirname(__FILE__) . '/../Lib/path/to/required.file.php';
使用ini_set( 'display_errors', 1 )
和error_reporting ( E_ALL )
您必須刪除文件../Lib/displaygrid.php的前兩行,代碼才能正常工作。
<script type="text/javascript" src="js_cookiefunctions.js"/>
<link rel="stylesheet" href="DGStyle.css" type="text/css">
順便說一句,您應該編寫更簡潔的代碼,並避免將演示文稿與代碼混淆
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.