Search code examples
phpcurlphpstorm

echo does not work in Curl in PhpStorm


I can not show output of curl.I use phpstorm with Xampp and echo dose not work. output in Browser in

502 Bad Gateway

<?php
$execution_time_limit = 25000;
set_time_limit($execution_time_limit);
header('Content-type: text/html; charset=utf-8');


    $url="https://stackoverflow.com/questions/ask";
    $data = getPage($url);
    echo $data;


function getPage($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_BUFFERSIZE, 5555500);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

Solution

  • first got to:

    C:\xampp

    and do that:

    • Just Run "xampp-control.exe" as administrator
    • and stop apache service action port.
    • and tick this(in snapshot) check box it will ask for install as service just install it
    • then click start

    enter image description here

    Integrating XAMPP with the IDE:

    1. Let's start by registering the PHP executable from XAMPP in PhpStorm. When in a PHP project, we can do this using the File | Settings menu (Ctrl+Shift+S or Cmd+Shift+S on Mac), navigating to the Project Settings | PHP.

    enter image description here

    1. With IntelliJ IDEA and PhpStorm, we can have several separate PHP interpreters registered in the IDE, depending on the PHP version and/or PHP configuration needed for the project. All currently registered installations of PHP interpreters are displayed in the Interpreter drop-down list: enter image description here

    We can add the one we've installed with XAMPP by clicking the Browse button (…). This will bring up the Interpreters dialog box. enter image description here