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

  • Home
  • SEARCH
  • 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 367069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:41:34+00:00 2026-05-12T13:41:34+00:00

So I have a PHP class called router that takes the URL and explodes

  • 0

So I have a PHP class called router that takes the URL and explodes it to find the requested component, action and any given values. It then loads the responsible class, runs the action, etc, etc. I am now integrationg user access into the class via an user class.

For each component (which is a class), I have a static class array variable called ‘perms’ that holds each action as an index and a number as the minimum permission needed to run the action. Each component also has a static function to get the permission value for the passed action name.

The problem I am having is getting the static function to work correctly with the name of the class stored in a variable. In the router I use a variable to hold the name of the component.

$this->controller // cms, calendar ,etc

I then add ‘Controller’ to it to get the name of the class

$class = $this->controller.'Controller'; // cmsController, calendarController, etc

However, I am getting an error when I try to use it to access the static function

$minActionPerm = $class::getPerms( $this->action ); // No go, parse error

I get no error when I literally type in the class name, but this is not a real solution.

$minActionPerm = cmsController::getPerms( $this->action ); // Good, but literal

The variable also works when I create an object of the class to run the action.

$object = new $class();

I’m sure it is probably just a simple answer – such as variable use, but it’s one I don’t know as of right now.

  • 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-05-12T13:41:35+00:00Added an answer on May 12, 2026 at 1:41 pm

    You need to use the call_user_func function.

    Example:

    call_user_func(array($class, 'getPerms'), $this->action);
    

    If you are using PHP 5.2.3+ you can also do it this way:

    call_user_func($class . '::getPerms', $this->action);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class called myClass in /myDir/myClass.php. When user types url: http://mysite.com/myDir/myClass.php, I
I have a php app that calls a class called Client. Every so often
I have a PHP class that creates a PNG image on the fly and
Let's say I have a PHP class called Color , it's constructor accepts various
I have created a PHP class called formChecker.php. It validates a form. As a
I have a php page that calls and runs a method called pagestart() in
So i have this class that includes some custom functions named class.php I have
i have a class that extends the PDO class. it's called Database. but in
I have a PHP class, once called, sets the time limit to 60 seconds.
I currently have my PHP class variables set up like this: class someThing {

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.