Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


error log: PHP Notice:  Only variable references should be returned by reference

Posted on 2011-02-21
Medium Priority
Last Modified: 2012-05-11
[Sat Feb 05 10:03:03 2011] [client] PHP Notice:  Only variable references should be returned by reference in /home/derm/fpdf/tutorial/Mail_Mime/mime.php on line 356, referer:

code error is referring to:

function &_addMixedPart()
        $params['content_type'] = 'multipart/mixed';
        return new Mail_mimePart('', $params);
Question by:phillystyle123
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 34948054
Are you trying to generate a pdf and email it?

Author Comment

ID: 34948344
yes - to clarify,the script already works -i'm just trying to figure out why i'm getting these log errors
LVL 16

Expert Comment

ID: 34948832

You can only return variables by reference, not the result of a statement.

Note the "&" before the function name.

Try this:

function &_addMixedPart()
        $params['content_type'] = 'multipart/mixed';
        $return = new Mail_mimePart('', $params);
        return $return;

Open in new window

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 34

Accepted Solution

Beverley Portlock earned 2000 total points
ID: 34949493
This little bug has been in the Mail_mime package for years. Just ignore it.

Expert Comment

ID: 34949530
Try the following w/out using mime.  

		$pdfdoc = $pdf->Output("example.pdf", 'S');

	$to = "";
	$from = "";
	$subject = "Subject";
	$message = "<p>Please see the attachment.</p>";
	$separator = md5(time());
	$eol = PHP_EOL; 
	$filename = "example.pdf";
	$attachment = chunk_split(base64_encode($pdfdoc));
	$headers = "From: ".$from.$eol;
	$headers .= "MIME-Version: 1.0".$eol;
	$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol;
	$headers .= "Content-Transfer-Encoding: 7bit".$eol;
	$headers .= "This is a MIME encoded message.".$eol.$eol;
	$headers .= "--".$separator.$eol;
	$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
	$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
	$headers .= $message.$eol.$eol;
	$headers .= "--".$separator.$eol;
	$headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
	$headers .= "Content-Transfer-Encoding: base64".$eol;
	$headers .= "Content-Disposition: attachment".$eol.$eol;
	$headers .= $attachment.$eol.$eol;
	$headers .= "--".$separator."--";

	if(mail($to, $subject, "$message", $headers)){
	<script type="text/javascript"><!--
    alert("Alert message!");
    window.location = "index.php";

Open in new window


Author Closing Comment

ID: 34975701

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question