Answer the question
In order to leave comments, you need to log in
Why does the code return a value only once?
Why does it return a value only once? And give an assessment to the code - where is something missing or something superfluous? Perhaps it could have been written more simply?
<?php
class parser {
protected $url;
protected $host;
protected $content;
protected $link;
protected $parsed;
protected $gotHost;
public function __construct($url) {
$this->url = $url;
}
public function parseIt() {
$content = file_get_contents($this->url);
preg_match("~<img src=\"(.*)\"~Uis", $content, $parsed);
$link = $parsed[1];
return $link;
}
public function getHost() {
$gotHost = parse_url($this->url, PHP_URL_HOST);
return $gotHost;
}
}
$parser = new parser('http://vk.com/id1');
echo $parser->parseIt();
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question