error while Imap parsing

I keep getting this error:
Parse error: syntax error, unexpected ‘imap_open’ (T_STRING) in C:\xampp\htdocs\Imap_parser.php on line 49

I dont understand what it is asking me to change so i cant get rid of the error, this is the code, can i ge tsome help please?
im not very familiar with php.

class Imap_parser {

function inbox($data)
{

	$result = array();
	
	$imap =  resource imap_open($data['email']['hostname'], $data['email']['username'], $data['email']['password']) or die ('Cannot connect to kraken.im: ' . imap_last_error());
	
	if ($imap) 
	{
		
		$result['status'] = 'success';
		$result['email']  = $data['email']['username'];
		
		$read = imap_search($imap, 'ALL');
		
		if($data['pagination']['sort'] == 'DESC')
		{
			rsort($read);
		}
		
		$num = count($read);
		
		$result['count'] = $num;
		
		$stop = $data['pagination']['limit'] + $data['pagination']['offset'];
		
		if($stop > $num)
		{
			$stop = $num;
		}
		
		for ($i = $data['pagination']['offset']; $i < $stop; $i++) 
		{
			
			$overview   = imap_fetch_overview($imap, $read[$i], 0);
			$message    = imap_body($imap, $read[$i], 0);
			$header     = imap_headerinfo($imap, $read[$i], 0);
			$mail       = $header->from[0]->mailbox . '@' . $header->from[0]->host;
			$image = '';
			
			$message = preg_replace('/--(.*)/i', '', $message);
			$message = preg_replace('/X\-(.*)/i', '', $message);
			$message = preg_replace('/Content\-ID\:/i', '', $message);
			
			$msg = '';            
			
			if (preg_match('/Content-Type/', $message)) 
			{
				$message = strip_tags($message);
				$content = explode('Content-Type: ', $message);
				foreach ($content as $c) {
					if (preg_match('/base64/', $c)) 
					{
						$b64 = explode('base64', $c);
						if (preg_match('/==/', $b64[1])) 
						{
							$str = explode('==', $b64[1]);
							$dec = $str[0];
						} else 
						{
							$dec = $b64[1];
						}
						if (preg_match('/image\/(.*)\;/', $c, $mime)) 
						{
							$image = 'data:image/' . $mime[1] . ';base64,' . trim($dec);
						}
					} else {
						if (!empty($c)) 
						{
							$msg = $c;
						}
					}
				}
			} else 
			{
				$msg = $message;
			}
			
			$msg = preg_replace('/text\/(.*)UTF\-8/', '', $msg);
			$msg = preg_replace('/text\/(.*)\;/', '', $msg);
			$msg = preg_replace('/charset\=(.*)\"/', '', $msg);
			$msg = preg_replace('/Content\-Transfer\-Encoding\:(.*)/i', '', $msg);
			
			$result['inbox'][] = array
			(
				'id' => $read[$i],
				'subject' => strip_tags($overview[0]->subject),
				'from' => $overview[0]->from,
				'email' => $mail,
				'date' => $overview[0]->date,
				'message' => trim($msg),
				'image' => $image
			);
			
			$result['pagination'] = array
			(
				'sort' => $data['pagination']['sort'],
				'limit' => $data['pagination']['limit'],
				'offset' => array
				(
					'back' => ($data['pagination']['offset'] == 0 ? null : $data['pagination']['offset'] - $data['pagination']['limit']),
					'next' => ($data['pagination']['offset'] < $num ? $data['pagination']['offset'] + $data['pagination']['limit'] : null)
				)
			);
			
		}
		
		imap_close($imap);
		
	} else 
	{
		$result['status'] = 'error';
	}
	
	return $result;
	
}

}

?>

remove resource from this:

[php]
$imap = resource imap_open($data[‘email’][‘hostname’], $data[‘email’][‘username’], $data[‘email’][‘password’]) or die ('Cannot connect to kraken.im: ’ . imap_last_error());
[/php]

I did that an now I get this error message:

Fatal error: Uncaught Error: Call to undefined function imap_open() in C:\xampp\htdocs\Imap_parser.php:49 Stack trace: #0 C:\xampp\htdocs\Kraken_web_parse.php(35): Imap_parser->inbox(Array) #1 {main} thrown in C:\xampp\htdocs\Imap_parser.php on line 49

sounds like your stack does not have the imap extension installed this post has more information https://stackoverflow.com/questions/9654453/fatal-error-call-to-undefined-function-imap-open-in-php

i came across that yesterday and i already did that through xampp

Sponsor our Newsletter | Privacy Policy | Terms of Service