Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this example, we want to get data from https://ipv4.netcurl.org which is a page that returns the content of your request as a json object. To get the json object correctly formatted so you don't have to parse it yourself we use getParsed()-method. Feel free to test here. If you explicitly need to test IPv6, you can use https://ipv6.netcurl.org for this.

Doing it on a simple row

A big difference between 6.0 and 6.1 is the chaining, which did not exist in the old versions as it supported PHP 5.3 in the "good old (horrible) times". Almost everything in netcurl 6.1 is chained, so the above method could be pushed into one simple row, like this:

Code Block
languagephp
themeEmacs
titleThe oneliner
 $parsed = (new NetWrapper())->request(sprintf('https://ipv4.netcurl.org/'))->getParsed();
static::assertNotEmpty(filter_var($parsed->ip, FILTER_VALIDATE_IP));