我在公共课程之外有一个变量。这个变量是:
$userid
我想在以下 PHP 类中使用该变量,但我遇到了问题:
public function printJavascript() {
if ($this) {
$page = $this - > page;
$order = (($this - > order) ? implode(':', $this - > order) : '');
$filter = (($this - > filter) ? implode(':', $this - > filter) : '');
}
echo "<script type=\"text/javascript\">\n";
echo "var params = ''; var tblpage = '".$page."'; var tblorder = '".$order."'; var tblfilter = '".$filter."';\n";
echo "function tblSetPage(page) { tblpage = page; params = '&page=' + page + '&order=' + tblorder + '&filter=' + tblfilter; updateTable(); }\n";
echo "function tblSetOrder(column, order) { tblorder = column + ':' + order; params = '&page=' + tblpage + '&order=' + tblorder + '&filter=' + tblfilter; updateTable(); }\n";
echo "function tblSetFilter(column) { val = document.getElementById('filter-value-' + column).value; tblfilter = column + ':' + val; tblpage = 1; params = '&page=1&order=' + tblorder + '&filter=' + tblfilter; updateTable(); }\n";
echo "function tblClearFilter() { tblfilter = ''; params = '&page=1&order=' + tblorder + '&filter='; updateTable(); }\n";
echo "function tblToggleCheckAll() { for (i = 0; i < document.dg.checkbox.length; i++) { document.dg.checkbox[i].checked = !document.dg.checkbox[i].checked; } }\n";
echo "function tblShowHideFilter(column) { var o = document.getElementById('filter-' + column); if (o.style.display == 'block') { tblClearFilter(); } else { o.style.display = 'block'; } }\n";
echo "function tblReset() { params = '&page=1'; updateTable(); }\n";
echo "</script>\n";
}
}
我将如何做到这一点?请提供建议,我感谢大家的帮助。