所以我有一个方法可以根据你传入的属性数组创建一个文本元素,除了 value 属性之外,它都可以工作,本质上问题如下:
如果某个值(无论是函数、文本还是您拥有的东西)被“回显”出来,则该值显示在框外,但是如果返回该值,那么我们将在标签内获取该值。
代码
function textarea(array $attributes){
   if(isset($attributes['name'])){
       $this->name = 'name="'.$attributes['name'].'"';
   }
   if(isset($attributes['id'])){
       $this->id = 'id="'.$attributes['id'].'"';
   }
   if(isset($attributes['class'])){
       $this->class = 'class="'.$attributes['class'].'"';
   }else{
       $this->class = 'class="aisisTextElement"';
   }
   if(isset($attributes['rows'])){
       $this->rows = 'rows="'.$attributes['rows'].'"';
   }
   if(isset($attributes['cols'])){
       $this->cols = 'cols="'.$attributes['cols'].'"';
   }
   if(isset($attributes['value'])){
       $this->value = $attributes['value'];
   }
   if(isset($attributes['style'])){
       $this->style = 'style="'.$attributes['style'].'"';
   }
   $build_aisis_element = '<textarea ' 
                          .$this->id 
                          .$this->class 
                          .$this->name 
                          .$this->rows  
                          .$this->cols 
                          .$this->style
                          .'>'.$this->value . '</textarea>';                
   echo $build_aisis_element;
} 
例如:
如果此函数作为值传入:
function echo_me(){
    echo "hello"
}
我的 html 看起来像:
hello
<textarea></textarea>
然而
function return_me(){
    return "hello"
}
我的html是:
<textarea>hello</textarea>
为什么是这样?