在php中包含.inc文件时出错

时间:2014-01-28 23:43:31

标签: php apache file include wamp

我想在我的php代码中包含一个inc扩展文件。但它呈现为纯文本,不会被解析。下面是我的php代码和inc文件。

inc file:

class Stack {

    private $stk = array();

    public function __construct() {
    }

    public function push($data) {
        array_push($this->stk, $data);
    }

    public function pop() {
        return array_pop($this->stk);
    }
    public function is_empty()
    {
     return empty($this->stk);
    }
}

php代码:

<?php
include('Stack.inc'); 
$s = new Stack();
  $a = array("a", "b", "c", "d", "e");
  foreach ($a as $val){
    $s->push($val);
  }

  while (!$s->is_empty()){
    echo "popping: {$s->pop()}\n";
  }
?>

我正在使用php的wamp服务器。我将httpd.conf文件更改为包含

<FilesMatch "\.inc$">
SetHandler application/x-httpd-php
</FilesMatch>

0 个答案:

没有答案