RE: [PHP] Missing arguments for function in class? (object-orientedprogramming)
| From: | Matt Williams | Date: | Thu, 28 Jun 2001 08:24:58 +0000 |
| Subject: | RE: [PHP] Missing arguments for function in class? (object-orientedprogramming) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-55460@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> I have a function that works perfectly (from within a script). But
> when I make it a class (object) and call it from an external file,
> I get the following error:
>
> Warning: Missing argument 1 for display_records() in
> http://www.friendshipcenter.com/Objects/display_records.inc
> on
> line 5
>
> Warning: Missing argument 2 for display_records() in
> http://www.friendshipcenter.com/Objects/display_records.inc
> on
> line 5
>
> After the warnings, it executes the function without passing values
> to the variables (i.e., it doesn't work), and then it executes the
> function a second time perfectly (with the appropriate variables).
>
> Line 5 is this:
>
> function display_records($row, $record_count)
>
> It displays the first error message for $row, and the second error
> message for $record_count.
Because your function has the same name as your class whenever you
create a new instance of the class the function will automatically
run.
So by creating a new class you are calling the function without
passing any arguments.
either
a) rename the function
or
b) call the class like this
$my_records = new Display_Records($row, $record_count);
sorry for any wrong use of terminology
HTH
M@
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBOzrpgaW0/zC+QxWwEQLkWwCg+ZTT0Kwld191fqnfQMNRKUEk9FYAoM8X
9oD3Bf5U9eTiGo/mRPU/dEEX
=rbZj
-----END PGP SIGNATURE-----