Home > Archive > PHP Language > October 2006 > other
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| If I write only this row
<?php var_dump(my_function(par1,par2,par3)); ?>
I have always the word NULL in the page,
preceded by value of the function (link)
| |
|
| On Tue, 24 Oct 2006 22:50:03 +0200, artev <mailnotspammm@notspamm.nn>
wrote:
>If I write only this row
><?php var_dump(my_function(par1,par2,par3)); ?>
>
>I have always the word NULL in the page,
>preceded by value of the function (link)
That's because your function is echoing or printing a value instead of
returning it. Here's a demonstration of the difference:
<?php
function my_function($foo) {
return $foo * 2;
}
var_dump(my_function(6));
?>
...prints out:
int(12)
...however,
<?php
function my_function($foo) {
echo $foo * 2;
}
var_dump(my_function(6));
?>
...prints out:
12NULL
The 12 is being printed out by the call to my_function(). The NULL is
being printed out because my_function() is not returning anything for
var_dump() to display.
hth
-
Remove mypants to email.
<http://www.shaunc.com/>
|
|
|
|
|