2009-11-13 57 views
0

我有一個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>";   
    } 
} 
?> 

我也想知道是否在第二個代碼中成功實現了與其他文件的鏈接?我的意思是,鏈接和腳本標籤在上面。

+1

你檢查HTML源代碼?可能有些東西沒有顯示出來,因爲你在一個表格行裏... – Franz 2009-11-13 11:08:11

+2

你的代碼很混亂。你至少應該把類和標記分開。包括cookie處理腳本和在錶行中間使用鏈接標記也不是一個好主意......如果您完全刪除了該類幷包含普通的PHP代碼,那麼您真的會變得更好...... – Palantir 2009-11-13 11:10:13

回答

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

可能包含路徑的問題?

嘗試:

require dirname(__FILE__) . '/../Lib/path/to/required.file.php'; 
1

使用ini_set('display_errors', 1)error_reporting (E_ALL)

1

你要刪除的文件../Lib/displaygrid.php的前兩行代碼的工作。

<script type="text/javascript" src="js_cookiefunctions.js"/> 
<link rel="stylesheet" href="DGStyle.css" type="text/css"> 

BTW,你應該寫乾淨的代碼,切忌混演示與代碼

相關問題