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

Posted on 2011-02-21
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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

LVL 34

Accepted Solution

Beverley Portlock earned 500 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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now