Simple PHP function and variable confusion
<p>I have a couple of simple PHP functions I am using. One to detect wether the user is on an iPhone, and one to resize images if they are.</p>

<pre><code>&lt;?php 

/* User agent function */
function userAgent(){
    $browser = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
    if ($browser == true)  { $var = 1; }
    return $var;
}

/* Image resize function */
function imageResize($width, $height) { 

    $var = userAgent($var);

    if($var == 1){
        $width = round($width / 2); 
        $height = round($height / 2); 
    }else{
        $width = round($width);
        $height = round($height);
    }

    echo "width=\"$width\" height=\"$height\""; 
} 

?&gt;
</code></pre>

<p>The problem is, if I manually change the $var to 0 or 1 in the userAgent() function, the images do not resize, but if I change the $var to == 0 in the imageResize() function, they do. </p>

<p>Why is the variable not carrying across from the first, to the second function, or am I doing something else wrong?</p>
