13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

842 Chapter 33 Connecting to <strong>Web</strong> Services with XML <strong>and</strong> SOAP<br />

Listing 33.11<br />

Continued<br />

foreach ($xml->SimilarProducts->SimilarProduct as $similar) {<br />

$this->similarProducts[$similarProductCount]['Title'] =<br />

(string)$similar->Title;<br />

$this->similarProducts[$similarProductCount]['ASIN'] =<br />

(string)$similar->ASIN;<br />

$similarProductCount++;<br />

}<br />

}<br />

}<br />

}<br />

// most methods in this class are similar<br />

// <strong>and</strong> just return the private variable<br />

function similarProductCount() {<br />

return count($this->similarProducts);<br />

}<br />

function similarProduct($i) {<br />

return $this->similarProducts[$i];<br />

}<br />

function customerReviewCount() {<br />

return count($this->reviews);<br />

}<br />

function customerReviewRating($i) {<br />

return $this->reviews[$i]['Rating'];<br />

}<br />

function customerReviewSummary($i) {<br />

return $this->reviews[$i]['Summary'];<br />

}<br />

function customerReviewComment($i) {<br />

return $this->reviews[$i]['Content'];<br />

}<br />

function valid() {<br />

if(isset($this->productName) && ($this->ourPrice>0.001) &&<br />

isset($this->ASIN)) {<br />

return true;<br />

} else {<br />

return false;<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!