Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8344827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:29:33+00:00 2026-06-09T06:29:33+00:00

So I have library called Engine.php and what it does basically is running example.com/controller/method/value

  • 0

So I have library called Engine.php and what it does basically is running

example.com/controller/method/value

So for example if I have

example.com/category/images

it runs the method called “images”. But I don’t want to add to the code for every single category. I want the method to be a variable (so that I will make it work with db later).

How can I achieve this without changing the Engine? The problem is – some of the pages don’t have categories at all. And I don’t want to rewrite the Engine itself.

Can I somehow do this in the controller? For example:

I’m entering controller called “category” and if method is set, it searches for this method within the controller (”category”).

This is what part of my Engine.php looks like:

    if (isset($url_output[1])) {
        if (isset($url_output[2])) {
            if (method_exists($controller,$url_output[1])) {
                $controller->{$url_output[1]}($url_output[2]);
            } else {
                $this->error();
            }
        } else {
            if (method_exists($controller,$url_output[1])) {
                $controller->{$url_output[1]}();
            } else {
                $this->error();
            }
        }
      }

So basically, as you can see:

$controller->{$url_output[1]}();

$url_output[1] = the name of the method in controller named $url_output[0].

What I want is:

public function $category() {
echo $category
}

You know what I mean?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:29:35+00:00Added an answer on June 9, 2026 at 6:29 am

    why don’t you make url like this

    example.com/category/index/images
    

    where index is a predefined function for category controller and images will be passes as first parameter to index function.

    Second option, bypass the index function in url.

    if (isset($url_output[1])) {
        if (method_exists($controller,'index')) {
            $controller->index($url_output[1]);
        } else {
            $this->error();
        }
    }
    
    class Category
    {
        function index($category)
        {
    
        }
    }
    

    use like this: example.com/category/images

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a class library called AddServiceLibrary in which I have a method
I have a library called example that I'm installing into my global site-packages directory.
I have this library called BASS which is an audio library which I'm going
I have a WinForms application (WF), and a Library called by that WinForms application
I have to import library which is called functions.sage . How can I do
My Scenario I have a class library that is going to be called from
I have two Services called TemplateService, TemplateReportService (both defined in one WCF Service Library)
I have a class (called Employee. non static) defined in a class library. I
I have an installed library called Gdal which runs certain GIS commands. This command
I have static C++ library, compiled with MSVC and dll file (library called opennurbs).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.