By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 2,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

Passing an Array to a Class

P: n/a
Bob
When I try to pass an array to a class the program hangs up.

php4, windows xp pro

This debug is going real slow due to having to reboot after every test
run.

Any help would be greatly appreciated!

the function in the calling program:

$new_session->set_serial_numbers('$serial_number_array');

usage in the class:

var $sn_array=array();

function set_serial_numbers($serial_number_array)
{$this->sn_array=$serial_number_array;}

for ($q=0;$q<count($this->sn_array);$q)
{echo $this->sn_array{$q}."<br>";}

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Bob wrote:

Hi Bob
$new_session->set_serial_numbers('$serial_number_array');


Should that be:
$new_session->set_serial_numbers("$serial_number_array");
???

You use ' and a variable inside ' do not get replace by its value.
It does inside "

$a = "hello";
echo "$a"; // output: hello
echo '$a'; // output: $a

not sure if that is the problem though, but it looks like a mistake.

Good luck,
Erwin Moller
Jul 17 '05 #2

P: n/a
Bob
No that is not it.
I just tried it, and I had to "halt the process".
Thanks for the try!
Bob

Jul 17 '05 #3

P: n/a
Bob wrote:
When I try to pass an array to a class the program hangs up.
<snip>
for ($q=0;$q<count($this->sn_array);$q)
{echo $this->sn_array{$q}."<br>";}


Where is $q changed in this loop?

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #4

P: n/a
Your problem is here:
$new_session->set_serial_numbers('$serial_number_array');

if you are passing an array you needn't use any form of quotes! This
will actually pass the string "array()"

Jul 17 '05 #5

P: n/a
Bob
That is it!
Bless your soul!
I was looking in the wrong place.
Many thanks.
Bob

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.