Forum


Replies: 5   Views: 3493
Only variables should be passed by reference
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by repunge  · 01-03-2017 - 09:48

Hi. I bought today basic version phpdocx and I have this problem:

ErrorException in HTML2WordML.inc line 958: Only variables should be passed by reference

Here is a code which generete that exception:

$docx = new CreateDocx();
$docx->embedHTML("<img src='http://www.somkiat.cc/wp-content/uploads/2016/07/ErrorMessage.jpg' />");
$docx->createDocx(public_path() . '/output.docx');

I havent any problem with trial version. Any help please?

Posted by admin  · 01-03-2017 - 14:45

Hello,

It seems one of the strings you are adding is not being readed correctly. Please run one of the included examples (Core/embedHTML/sample_1.php) to test the conversion from HTML to DOCX using a tested script and then try to run each your script standalone (using PHP CLI for example) to know where the error comes from.

This simple script runs perfectly:

<?php

require_once 'classes/CreateDocx.inc';

$docx = new CreateDocx();
$docx->embedHTML("<img src='http://www.somkiat.cc/wp-content/uploads/2016/07/ErrorMessage.jpg' />");
$docx->createDocx('output.docx');

Maybe $body var has something wrong in it or if you are integrating it with a CMS or framework there's some error in how to have integrated the library. Please try to run your script standalone (out of any CMS or framework).

The trial package is the same than the Basic package but with the document properties overwritten, and image and text watermarks.

Regards.

Posted by repunge  · 02-03-2017 - 02:41

Hi. Error comes with this line:
$docx->embedHTML("<img src='http://www.somkiat.cc/wp-content/uploads/2016/07/ErrorMessage.jpg' />");
No problem with:
$docx->embedHTML("<p>dsadsa</p>);
-------------------------
Strange thing is. When I run on localhost I dont see any problem but when I run it on real server then I got his error: Only variables should be passed by reference.

Posted by repunge  · 02-03-2017 - 03:51

ErrorException in HTML2WordML.inc line 958: $descr = array_shift(explode('?', $descr));

Posted by repunge  · 02-03-2017 - 04:12

Hi. I fixed that now. I have replaced this:

//$descr = array_shift(explode('?', $descr));
to that:
$tmpA = explode('?', $descr);
$descr = array_shift($tmpA);
--------------

and the same with //$extension = array_shift(explode('?', $extension));

Posted by admin  · 02-03-2017 - 08:23

Hello,

We are going to check it. It must be an issue from a Strict mode of some versions of PHP. You could config your server to avoid strict messages; although the change you have done will work perfectly.

Regards.