Lukeidiot Posted January 27, 2014 Share Posted January 27, 2014 Hello fine people, I have a question today. Here is my code: My question is: How do I pass this function(image below) into my static variable? I tried CURLOPT_PROXY => self::getProxy(), But this didn't work. Any ideas? Link to comment https://forums.phpfreaks.com/topic/285700-public-static-variables-question/ Share on other sites More sharing options...
requinix Posted January 27, 2014 Share Posted January 27, 2014 You can't do it like that. You have to use a separate line of code to do an assignment. You need to use those options at some point, right? Use the $CURL_OPTIONS as a template and then provide the specific information (ie, the CURLOPT_PROXY value) at runtime. $options = self::$CURL_OPTIONS; $options[CURLOPT_PROXY] = $this->getProxy(); Link to comment https://forums.phpfreaks.com/topic/285700-public-static-variables-question/#findComment-1466679 Share on other sites More sharing options...
Lukeidiot Posted January 27, 2014 Author Share Posted January 27, 2014 You can't do it like that. You have to use a separate line of code to do an assignment. You need to use those options at some point, right? Use the $CURL_OPTIONS as a template and then provide the specific information (ie, the CURLOPT_PROXY value) at runtime. $options = self::$CURL_OPTIONS; $options[CURLOPT_PROXY] = $this->getProxy(); What's the best way to add those options to this: I ask because when I assign the options, its also in array (making $options[CURLOPT_PROXY] = $this->getProxy(); throw an error because of the parenthesis) Link to comment https://forums.phpfreaks.com/topic/285700-public-static-variables-question/#findComment-1466686 Share on other sites More sharing options...
kicken Posted January 27, 2014 Share Posted January 27, 2014 You use the same format as your other options. CURLOPT_PROXY => $this->getProxy() That or add the $options[CURLOPT_PROXY] = $this->getProxy(); on the next line by itself. Link to comment https://forums.phpfreaks.com/topic/285700-public-static-variables-question/#findComment-1466687 Share on other sites More sharing options...
Lukeidiot Posted January 27, 2014 Author Share Posted January 27, 2014 You use the same format as your other options. CURLOPT_PROXY => $this->getProxy() That or add the $options[CURLOPT_PROXY] = $this->getProxy(); on the next line by itself. Ah yeah! Works perfectly! Link to comment https://forums.phpfreaks.com/topic/285700-public-static-variables-question/#findComment-1466789 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.