I dont understand the function of these characters -> in this code:

$var->getImageInfo();



the function "getImageInfo()" populates the variable "$var".

I can use the print_r function to display all values but how do I get a specific value


echo "<pre>";
print_r($var->getImageInfo());
echo "</pre>";

returns

Array
(
    [resolutionUnit] => 0
    [fileName] => 1.jpg
    [fileSize] => 30368 bytes
    ...
)

how do I get "fileSize" for instance?

Accepted Answer

In your example, $var->getImageInfo(), the variable $var is an instance (also called an object) of a class. The function getImageInfo() is known as a class method. This is part of Object Oriented Programming, also called OOP. You can learn more about this here - http://php.net/manual/en/language.oop5.php

If you want to get a particular member of the array that you listed, you can simply do:

$image_info = $var->getImageInfo();
echo $image_info['fileSize'];
Written by Charles Hooper
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki