We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,078 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Unlimited arguments in URL and fetching them automaticly

Hey there DaniWeb!

I have been working a little bit on a framework, and i've came to a little problem:(

I want my URL's to be like CodeIgniters where it'll be:

site.com/modulename/function/arg1/arg2/arg3 and so on..

and i was thinking it could be be done with something like this (pseudo-code):

$args = array();

foreach($_GET as $g) {
    if($g == "arg" . (WILDCARD / NUMBERS ONLY)) {
        $args[] = $g;
    }
}

$module = $_GET['m'];
$function = $_GET['f'];

require_once($module . ".php");

$m = new $module;

echo $m->$function(Some way to make all args in here with commas);

Could anyone possible come up with something like that? ^^

Thanks for reading, and i hope you understand my idea! :-)

3
Contributors
12
Replies
23 Hours
Discussion Span
7 Months Ago
Last Updated
13
Views
Weliaz
Light Poster
25 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

@Weliaz

I want my URL's to be like CodeIgniters where it'll be:
site.com/modulename/function/arg1/arg2/arg3 and so on..

I haven't work or test on CodeIgniters yet, it's on my server. Have you read the user guide on CodeIgniters? The user guide show you how each code works:

http://codeigniter.com/user_guide/general/urls.html

http://codeigniter.com/user_guide/helpers/url_helper.html

LastMitch
Industrious Poster
4,165 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

Don't really get anything out of that:/

Weliaz
Light Poster
25 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

@Weliaz

Could anyone possible come up with something like that? ^^

No

I have been working a little bit on a framework, and i've came to a little problem:(

How long have you work on a Framework? It's on OOP. If you are familiar with it then the code should be much easier to understand unless this is your first code you wrote or you just used someone else code and modify it.

Don't really get anything out of that:/

I thought you want to get this:

site.com/modulename/function/arg1/arg2/arg3

The link I provided does have that example in it.

LastMitch
Industrious Poster
4,165 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

I indeed want something like that, however the link does not provide me with any method to complete that wish.

Weliaz
Light Poster
25 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

@Weliaz

I indeed want something like that, however the link does not provide me with any method to complete that wish.

I'm not familiar with CodeIgniters but base on the example you provide it's missing something.

In order to get this:

site.com/modulename/function/arg1/arg2/arg3

you have to follow the instructions on this website:

http://codesamplez.com/development/codeigniter-routes-tutorial

plus read this:

http://codeigniter.com/user_guide/general/urls.html

then you will get what you want.

LastMitch
Industrious Poster
4,165 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

I don't think you completely understood my request.

I don't need something to integrate with CodeIgniter. I am making my very own framework, and need something like CodeIgniters URL routing.

Weliaz
Light Poster
25 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

OK so this is .htaccess?

site.com/modulename/functionname/arg1/arg2/arg3

relates to what?

site.com/index.php?module=modulename&function=functionname&a1=arg1&a2=arg2&a3=arg3

if so:

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /index.php?module=$1&function=$2&a1=$3&a2=$4&a3=$5 [L]
diafol
Keep Smiling
Moderator
10,655 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,511
Skill Endorsements: 57

I need both .htaccess and PHP code.

And that script ain't exactly right.

What i need is an unlimited amount of "args", which means that it won't just be arg1,2,3 but can continue forever.

I need .htaccess code for that + a PHP code to parse it.

Weliaz
Light Poster
25 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

@Weliaz

I need both .htaccess and PHP code.

And that script ain't exactly right.

I feel you are asking a lot.

Regarding about the mainframe. I thought you were using a mainframe. But you never mention about creating your own mainframe.

I think you need to hired someone to do this. I really doubt any DaniWeb member will take that much time provide such a code.

LastMitch
Industrious Poster
4,165 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

"I have been working a little bit on a framework, and i've came to a little problem:(

I want my URL's to be like CodeIgniters where it'll be:"

I think that kinda tells that i'm working on my own framework.

Weliaz
Light Poster
25 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
diafol
Keep Smiling
Moderator
10,655 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,511
Skill Endorsements: 57

@Weliaz

"I have been working a little bit on a framework, and i've came to a little problem:(

I want my URL's to be like CodeIgniters where it'll be:"

I think that kinda tells that i'm working on my own framework.

I think your question is more vague than precise.

LastMitch
Industrious Poster
4,165 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.1033 seconds using 2.72MB