是这样的,楼主可以参照http://cn2.php.net/manual/zh/function.dom-domcomment-construct.php这个PHP手册的范例,PHP手册的范例是绝对没有错误的。

解决方案 »

  1.   

    <?php$dom = new DOMDocument('1.0', 'iso-8859-1');
    $element = $dom->appendChild(new DOMElement('root'));
    $comment = $element->appendChild(new DOMComment('root comment'));
    echo $dom->saveXML(); /* <?xml version="1.0" encoding="iso-8859-1"?><root><!--root comment--></root> */?>范例是这样写参数的,所以楼主的方法是正确的
      

  2.   

    <?php
    class Person {
        private $name;
        /**
         * Php5 构造函数写法
         * @param String $name
         */
        public function  __construct($name) {
            $this->name = $name;
        }
       /**
         * 4中的写法
         * @param String $name
         */
        /**
          public function Person($name){
            $this->name = $name;
         }
         */
        public function getName(){
            return $this->name;
        }
    }
    $person = new Person('PersonA');
    echo $person->getName();
    ?>