I believe your issue is because you're trying to pass the result of a function call that isn't returning a reference to a function whose parameter is defined to accept a reference.
This is what is stated in the manual:
The following things can be passed by reference:
- Variables, i.e. foo($a)
- New statements, i.e. foo(new foobar())
- References returned from functions
fopen
isn't returning a reference, so trying to call it inline while passing a parameter to a function accepting a reference isn't valid. Try this:
$fp = fopen($source, 'rb');
$source_file = $s3->inputResource($fp, filesize($source));
The manual describes this example as valid (because bar()
returns a reference):
<?php
function foo(&$var)
{
$var++;
}
function &bar()
{
$a = 5;
return $a;
}
foo(bar());
?>
And this example is invalid (which is what I think is happening):
<?php
function foo(&$var)
{
$var++;
}
function bar() // Note the missing &
{
$a = 5;
return $a;
}
foo(bar()); // Produces fatal error since PHP 5.0.5