Jump to content

help with a function please...


brown2005

Recommended Posts

You have to echo the function if you are just returning a value in the function
This
[code]<?php
function my($word1, $word2)
{
return "$word1 - $word2";
}

$word1 = "CABBAGE";
$word2 = "APPLES";
echo my($word1,$word2);
?>[/code]

Works just like this
[code]<?php
function my($word1, $word2)
{
echo "$word1 - $word2";
}

$word1 = "CABBAGE";
$word2 = "APPLES";
my($word1,$word2);
?>[/code]

Also your parameters to not have to be $word1 and $word2
[code]<?php
function my($word1, $word2)
{
echo "$word1 - $word2";
}

$field1 = "CABBAGE";
$field2 = "APPLES";
my($field1,$field2);
?>[/code]
The $word1 and $word2 are use by the function. when you call the function those 2 parameters are automatically applied to $word1 and $word2.

Ray

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.