Re: function()
| From: | Joshua E Minnie | Date: | Tue, 05 Nov 2002 16:07:51 +0000 |
| Subject: | Re: function() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-122790@lists.php.net to get a copy of this message | ||
First of all, you can't echo that variable in the manner you are trying.
Try this instead:
[lib.inc]
function test_func($param1) {
return $param1;
}
[main.php]
<?php
// option 1
$num = test_func(123);
echo $num;
// option 2
echo test_func(123);
?>
HTH
_________________
/ Joshua Minnie \
+ +-------------------------------+
| Wild Web Technology |
| Independent Web Consultant/Developer |
| josh@wildwebtech.com |
| |
| Tel : 616.890.1566 |
+----------------------------------------------------+
"Francisco Vaucher" <fvaucher@tycoint.com> wrote:
| Hi to all,
|
| I have a problem with function() and some variables.
|
| The issue is this
|
| I declare the function, suppose:
|
| function test_func($param1) {
| echo $param1;
| }
|
| when I call the function like;
|
| <?php test_func(123)?>
|
| works OK!
|
| But if I try something like this:
|
| <?php
|
| test_func(123);
| echo $param;
|
| ?>
|
| This doesn't work. I need to get some variables values out of the
function.
| Is there a way to make te variables defined in the function 'global' ? So
I
| can use them after the function call.
|
| Thanks in advance!!
|
| regards,
|
| f.
|