p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Included Function's Parameters are Not Passed In


Message #1 by "Trey Carroll" <treycarroll@y...> on Fri, 25 Oct 2002 00:27:18
I include a file that contains a single php function, but when I call the 
function, my parameters aren't coming through.  I checked the values 
BEFORE sending them as parameters and they ARE set correctly to non-zero 
values.

<?
//file1.php
include("file2.php");
  . . .
foo($result,$b,$c,$d);
?>


<?
//file2.php

foo(&$result,&$intB,$intC,$strD)
  {
   echo "result=$result<br>";
   echo "intB=$intB<br>";
   echo "intC=$intC<br>";
   echo "strD=$strD<br>";
  }
?>

OUTPUT:
result=Resource id #2
intB=0
intC=0
strD=
Message #2 by "Nikolai Devereaux" <yomama@u...> on Thu, 24 Oct 2002 19:16:07 -0700
It works for me, except you forgot the "function" keyword in front of the foo()
definition.

That zeros are being printed in the intB and intC spaces is strange to me,
because strD is blank.  You'd think that if none of the vars were coming
through, then they'd either all be blank or all be zero, not mixed.


That the function is defined in an include file should not make any
difference -- have you tried it with the function inside of file1.php? (and
without including file2.php, obviously)

nik


  Return to Index