Skip to content

Instantly share code, notes, and snippets.

@danialdezfouli
Created May 3, 2021 15:12
Show Gist options
  • Save danialdezfouli/7f6eaa4e6b08ac302063a23a55a00fee to your computer and use it in GitHub Desktop.
Save danialdezfouli/7f6eaa4e6b08ac302063a23a55a00fee to your computer and use it in GitHub Desktop.
Simple Class to Fetch a URL
<?php
class Domain
{
protected $path;
function __construct($domain = 'https://www')
{
$this->path = $domain;
}
function __get($domain)
{
return new Domain($this->path ? $this->path . '.' . $domain : $domain);
}
function __toString()
{
return file_get_contents($this->path);
}
}
$www = new Domain();
echo $www->example->com;
@tayyebi
Copy link

tayyebi commented May 3, 2021

That got me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment