override an array from different Method

最后都变了- 提交于 2021-01-29 17:22:29

问题


I would like to add an curl Option in the method listDir to be able to list the files the connection method works just fine but when am trying to append the cOptions array and add $this->cOptions[CURLOPT_CUSTOMREQUEST]="PROPFIND";

it doesn work!!!! and help clue what to do?

thanks in Advance

<?php

class test{
   
   public static $cOptions;
   
   public function connect(){
      
      $ch = curl_init();

      $this->cOptions=array(
         CURLOPT_URL =>"111",
         CURLOPT_RETURNTRANSFER=>1
      );
      
      
      $response = curl_exec($ch);
      curl_close($ch);
      return $response;      
      
   }
   
   public function listDir(){
      
       $this->cOptions[CURLOPT_CUSTOMREQUEST]="PROPFIND";
       $connection=$this->connect();
      
      return $connection; ///// should list files
   }
}
$myclass=new test();
 $myclass->connect();
$myclass->listDir();


来源:https://stackoverflow.com/questions/65554185/override-an-array-from-different-method

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!