Jump to content


Photo

Missing Argument?


  • Please log in to reply
2 replies to this topic

#1 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 16 March 2006 - 09:25 PM

First question: How can you show the folder before, for example: "/upload/lpxxfaintxx/category2" NOT just "category2".

<?php
function this_folder_name($path){
   if (!$path){$path=$_SERVER['PHP_SELF'];}
   $current_directory = dirname($path);
   $current_directory = str_replace('\\','/',$current_directory);
   $current_directory = explode('/',$current_directory);
   $current_directory = end($current_directory);
   return $current_directory;
}
print this_folder_name();
?>

[/quote]

Question 2:

Warning: Missing argument 1 for this_folder_name(), called in C:\wamp\www\aimphotogallery\ownmod\foldername.php on line 17 and defined in C:\wamp\www\aimphotogallery\ownmod\foldername.php on line 9
ownmod[/quote]

The script works, but the error keeps on popping up. Its starting to bug me, is there any solution?

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 16 March 2006 - 09:58 PM

Yes..

You have declared the function with a parameter. That means when you want to call that function you must pass a parameter to it.

ie

function urfunc ($param) {
...
return $string;
}

print urfunc(); // this will fail as you have no parameter.

print urfunc('word_or_var'); // this will work as there is a parameter being passed.


If you don't want to pass a parameter you can define default values for parameters so that passing them is not neccessary.

function urfunc ($param = 'default_val') {
...
return $string;
}


follow me on twitter @PHPsycho

#3 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 16 March 2006 - 10:00 PM

Thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users