Jump to content

Missing Argument?


lpxxfaintxx

Recommended Posts

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

[code]
<?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();
?>[/code]

[/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?
Link to comment
https://forums.phpfreaks.com/topic/5110-missing-argument/
Share on other sites

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;
}

Link to comment
https://forums.phpfreaks.com/topic/5110-missing-argument/#findComment-18135
Share on other sites

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.