I have a method that requires two variables to pass through it but for some reason the second one doesn't. I've tried tons of stuff but nothing seems to work.

function get_area_number($area, $company='daniweb'){
	echo '>> '.$company;
}

Thats the method, nothing is displayed for the $company echo unless I declare it just before the echo. This is how I call it

$area_number = $get_area->get_area_number('an area','daniweb');// Doesn't work
$area_number = $get_area->get_area_number('an area');// Doesn't work
$area_number = $get_area->get_area_number('an area',$daniweb);// Doesn't work

I don't know where to go from here so I was hoping someone here would have an idea, any feedback is appreciated.

Of course you want to use a return not an echo ... right

<?php
class Get_Area {
  public function get_area_number( $area, $company='daniweb' ){
    echo "$company\n";
    return $company;
  }
}

$get_area = new Get_Area();

$area_number = $get_area->get_area_number('an area','daniweb'); // Works
$area_number = $get_area->get_area_number('an area'); // Works
$daniweb = 'daniweb';
$area_number = $get_area->get_area_number('an area',$daniweb); // Works

echo $area_number;
?>

Well the method does alot more, I'm just using the echo to see if anything is coming through the parenthesis, $company isn't. I do eventually return a variable but its a long script and irrelevant to the problem at hand.

If I have

function get_area_number($area,$company='daniweb'){
	$company = 'daniweb';
	echo '>> '.$company;

it displays
>> daniweb

I'm really lost with this error :confused:

The snippet I posted works, based off your original post. Therefore the issue is being produced somewhere in the code you did not show us...

Let's have a look.

Well do I feel like a tit or what.

I was actually working off of a back-up file I have in a different directory and so while the code was the same and the file name was the same the page I was viewing in my browser wasn't being affected.:|

Thanks for your response and sorry for wasting your time :D

I don't even want to say how many times I've done that...and after a decade of programming you think I would consider that when the changes I'm making aren't having any effect.

Ciao

This question has already been answered. Start a new discussion instead.