To my smartest friends, I googled and tried everything. I am sure that this is just the late night not letting me see/understand the problem. I should mention that I am still in the process of switching to OOP from functional, and I this is my first time I was able to have curl enabled. :( So, feel free to critique any bad practices also..
<?php
class urlValidation
{
public $content;
public $validUrl;
public function __construct($validUrl)
{
$this->content = $content;
$this->validUrl = $validUrl;
$this->getContents();
}
public function getContents()
{
$this->curlHandler = curl_init($this->validUrl);
curl_setopt($this->curlHandler, CURLOPT_NOBODY, false);
curl_setopt(CURLOPT_RETURNTRANSFER, false); //changing false to true is the answer!
$this->content = curl_exec($this->curlHandler);
curl_close($this->curlHandler);
}
}
?>
called from
$suggestUrl = 'http://www.google.com';
$validate = new urlValidation($suggestedUrl);
For all of the best of me, I cannot figure out why $this->content prints to the screen without being called. I just simply want that returned HTML to be stored in a variable and not returned/printed/appended to the document.
$this->content=$contentin the constructor, which doesn't make a lot of sense - where does$contentcome from? And lastly, it's a good practice to stick to conventions, so why not start a class's name with a capital letter.