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 8098261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:01:39+00:00 2026-06-05T22:01:39+00:00

I have a php class, RegistrationController, <?php class RegistrationController extends ParentController { function __construct()

  • 0

I have a php class, RegistrationController,

<?php
 class RegistrationController  extends ParentController {

    function __construct() {
        parent::__construct();
        echo 'We are inside RegistrationController';
    }

    public function register() {
        $name = $_GET['name'];
        echo "<li> We will register soon, $name </li>";
    }
 }
?>

I am accessing the register method via URL like this, [FYI, I am using RewriteEngine in .htaccess]

http://localhost:8888/Service/RegistrationController/register?name=Owl

Question

Now, everything works fine, I just need to make sure my queries have those ?name=Owl variables set when I request some computation.

The web service will not be accessible from Web Browser it’s just a trivial service I want to made for my Mobile application. The application will be calling this URL as it is without any change except the details (var).

So, is it okay to $_GET or $_POST inside class’s function? Is it scalable or maintainable?


Additional Info

I am calling the methods of different controllers in very generic manner, so In my Bottstrap I am just calling this function which lets me call any controller’s method with few lines.

private function handleMethodCallOn($controller, $url) {
        //check if the URL has specified any method to call
        if(isset($url[1])) {//URL has been exploded earlier to get content
            if(method_exists($controller, $url[1])) {
                $controller->{$url[1]}();//HERE I am calling any function
            } else {
                $error = new error_404();
            }   
        }
    }
  • 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-05T22:01:41+00:00Added an answer on June 5, 2026 at 10:01 pm

    It is perfectly viable to use post and get inside a class method. What jumps out at experienced devs about your code is more likely to be 2 things:
    1. lack of input validation
    2. dumping user input directly into your page’s output (one can only hope that you aren’t doing similar things on the way into the database).

    If you are not interested in using a framework, you can do these things manually.
    However, there are myriad solid PHP frameworks which can bootstrap a RESTful request for you, abstracting it into an object, rich with input validation and the like.

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

Sidebar

Related Questions

I have one PHP class thus: class DB extends mysqli{ public function __construct( {
I have following php class class User implements IUser { public function __construct($i_objParent =
So far I have a PHP class with the constructor public function __construct ($identifier
I have this PHP class class myclass{ function name($val){ echo this is name method
I have a php classes like: class bar{ public $value; } class foo extends
i have one php class class veh extends dbClass { function smo($id) { $query=select
I have a PHP class with a static function: <? echo view::getUserSelector() ?> Which
i have next php code <?php class A { public function foo() { }
If I have a PHP class such as this one: class A { public
This is what I have in foo.php class Foo { public $foo = NULL;

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.