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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.