Php 如何在括号零件中设置会话变量的格式

Php 如何在括号零件中设置会话变量的格式,php,jquery,variables,session,tablesorter,Php,Jquery,Variables,Session,Tablesorter,我使用表排序器。在设置会话cookie之前的页面中 tablesorter有以下部分: $.tablesorter.setFilters( table, ['', 'test' ], true); 现在我需要session变量,单词“test”在哪里,但我不知道如何格式化它 是这样的吗? $.tablesorter.setFilters( table, ['', ($_SESSION["favcoloor"]) ], true); $.tablesorter.setFilter

我使用表排序器。在设置会话cookie之前的页面中

tablesorter有以下部分:

   $.tablesorter.setFilters( table, ['', 'test'  ], true);
现在我需要session变量,单词“test”在哪里,但我不知道如何格式化它

是这样的吗?

  $.tablesorter.setFilters( table, ['', ($_SESSION["favcoloor"]) ], true);
 $.tablesorter.setFilters( table, ['', '($_SESSION["favcoloor"])' ], true);
  $.tablesorter.setFilters( table, ['', $_SESSION["favcoloor"] ], true);
或者像这样:

  $.tablesorter.setFilters( table, ['', ($_SESSION["favcoloor"]) ], true);
 $.tablesorter.setFilters( table, ['', '($_SESSION["favcoloor"])' ], true);
  $.tablesorter.setFilters( table, ['', $_SESSION["favcoloor"] ], true);
或者像这样:

  $.tablesorter.setFilters( table, ['', ($_SESSION["favcoloor"]) ], true);
 $.tablesorter.setFilters( table, ['', '($_SESSION["favcoloor"])' ], true);
  $.tablesorter.setFilters( table, ['', $_SESSION["favcoloor"] ], true);


我无法让它工作,请帮助我设置正确的格式。

您需要将PHP中的会话变量回显到jQuery代码中:)

$.tablesorter.setFilters(表,['',],true);
如果已启用,则可以使用以下选项:

$.tablesorter.setFilters( table, ['', '<?=$_SESSION["favcoloor"];?>' ], true);
$.tablesorter.setFilters(表,['',],true);

@tijnn如果根据所问问题,任何答案满足您的要求,那么您必须接受该答案。如果其他用户遇到与您相同类型的问题,这将有助于他们。