S
S
Sergey Beloventsev2017-04-14 21:28:12
Yii
Sergey Beloventsev, 2017-04-14 21:28:12

What's with the weird curl error?

I'm trying to save partner sites in yii2 on the topic of whether the product is in stock, I organized it using this method

public function haveParse($goods){
        $ch = curl_init();
        $url="$goods->url";
        curl_setopt($ch, CURLOPT_URL, $url);
        return curl_exec($ch);
    }

comes the followingboolean true
var_dump($goods->url)==string 'http://xn----7sblaeg7cgj4a.com.ua/ve6rhnjaja-odejda/3339-palto-frak.html'
if here curl_setopt($ch, CURLOPT_URL, $url);replace with
curl_setopt($ch, CURLOPT_URL, 'http://xn----7sblaeg7cgj4a.com.ua/ve6rhnjaja-odejda/3339-palto-frak.html');
the page is complete. Don't tell me what's the problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Arkh, 2017-04-14
@Sergalas

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $goods->url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
return curl_exec($ch);

M
Maxim Timofeev, 2017-04-14
@webinar

$url="$goods->url";- Quotes why? It's the same variable. You write the string $goods->url" in $url and not the value from the variable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question