3

您好我正在使用以下代码来显示表格,但它显示了这样的错误。

Warning: require(HTML/Table.php) [function.require]: failed to open stream: No such file or directory in /home/aspire/public_html/table.php on line 3

Fatal error: require() [function.require]: Failed opening required 'HTML/Table.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/aspire/public_html/table.php on line 3

这是我的代码。谁能告诉我我犯了什么错误。

 require("HTML/Table.php");
 $tableStyle = array("bgcolor"=>"#FFFFFF", "border"=>"1", "width"=>"150",   "cellpadding"=>"1", "cellspacing"=>"2"); 
 $colA = array("field 1", "field 2", "field 3", "", "<b>TOTAL</b>");
 $a = 10;
 $b = 15;
 $c = 8;
 $total = $a+$b+$c;
 $colB = array($a, $b, $c, "", "<b>".$total."</b>");
 $table = new HTML_Table($tableStyle);
 $table->addCol($colA);
 $table->addCol($colB);
 $table->display();

使用这个“ php go-pear.phar ”命令我找到了以下路径。

Current include path           : .:/usr/share/php:/usr/share/pear
Configured directory           : /home/aspire/pear/share/pear
Currently used php.ini (guess) : /etc/php5/cli/php.ini

因此,在开始我的代码之前指定路径时

 include_path=".:/usr/share/php:/usr/share/pear/";

它显示了类似的错误

Parse error: syntax error, unexpected '=' in /home/aspire/public_html/table.php on line 2

如何解决这个问题呢。

4

2 回答 2

1

尝试您的示例代码,我收到错误消息:

PHP Warning:  require(HTML/Table.php): failed to open stream: No such file or directory in /home/dylan/Desktop/scratch/pear_path.php on line 3
PHP Fatal error:  require(): Failed opening required 'HTML/Table.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/dylan/Desktop/scratch/pear_path.php on line 3

我解决了这个问题,并且该程序在执行以下操作后似乎可以正常工作:

sudo pear install HTML_Table

如果您遇到问题包版本,您可以尝试 pear force 选项。

sudo pear install -f --alldeps HTML_Table

我在这里找到了这个:http: //grokbase.com/p/php/pear-general/05ak6rnj7m/pear-problem-installing-db-dataobject-formbuilder-frontend

于 2012-12-15T06:36:46.973 回答
0

设置包含路径的正确方法是:

set_include_path(".:/usr/share/php:/usr/share/pear/");
于 2012-12-15T07:03:28.130 回答