Using External variable in a function of a class

I’m trying to pass a variable in another class calling it on top of the class… something like this…


include_once('classes/profile.class.php');
$email=$profile->getField('email'); //<-- the email address prints here if ecoed but doesn't work inside the class .. example below..
class someClass
{

public function show_answer($id, $ticketInfo)
		{
			if($ticketInfo->res == "true")
			{
				$this->_ticketInfo = new ticketInfo();
				echo '<article style="margin-top:-18px;">
							<section class="well well-small mePadd">
								<h2 class="meFont" style="padding-bottom:30px;"><span class="icon-comment meMarg"></span> Answer</h2>';
				for ($i = 0; $i < count($ticketInfo->id); $i++)
				{
					if($ticketInfo->id[$i] == $id)
					{
						$message = urldecode($ticketInfo->msg[$i]);
						$message = str_replace("\\'", "'", $message);
						$user_name = $this->_ticketInfo->getuser($ticketInfo->userId[$i]);
						$user_name = json_decode($user_name);
						if(empty($user_name))
						{
							$full_name = "this user deleted";
						}
						else
						{
							$full_name = $user_name->name.' '.$user_name->lastname;
						}
						$dateModified = self::change_date_format($ticketInfo->dateAded[$i]);
						$dateActivity = self::change_date_format($ticketInfo->dateActivity[$i]);
						$adminInfo = self::getAdminInfo($email); //<-- this variable $email is not being able to pull the email address
... rest of the code


}

}

Any idea why $email is not being pulled up there?

Thanks

You’ll need to use the global keyword in order to use a global variable.

That being said, don’t use global variables. Your code will harder to understand and predict, harder to reuse and test, and errors will be easier to make and harder to trace.