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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:09:47+00:00 2026-05-22T01:09:47+00:00

I have a php file that creates a json output. my problem is that

  • 0

I have a php file that creates a json output. my problem is that i will need lots of functions that return json data. For example:

  1. i will need to fetch a list of all customers in a given db;
  2. I will need to fetch all vehicles from a given customer;
  3. i will need to fetch all data from a given vehicle

and so on. At this point i can have all this working if each function is in a separate php file. The complexity of this is only going to increase and i dont want to have lots of files cluttering the file system. Is there a way around this? any practical example would be appreciated

  • 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-22T01:09:47+00:00Added an answer on May 22, 2026 at 1:09 am

    Sure. If you have one function for each type of action, like this:

    function action_hello_world() {
        echo "Hello, world!";
    }
    function action_hello() {
        echo "Hello, {$_GET["name"]}!";
    }
    

    Then create an array of valid actions:

    $valid_actions=array("hello_world", "hello");
    

    Then we have a GET parameter called action:

    $action=$_GET["action"];
    

    We check to make sure it’s valid…

    if(!in_array($action, $valid_actions)) {
        die("Invalid action.");
    }
    

    Then we call the correct function:

    $function_name="action_$action";
    $function_name();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, currently I have my SWF hitting a php file that will go and
I have a php file that outputs json encoded text via echo '(' .
i have a script that calls a php file and gets an JSON object
I have a PHP script that dynamically creates a HTML file. In command line,
I have a php file that returns a string like this [item1,item2,item3,item4] I need
I have a PHP script that processes file uploads. The script tries to organise
I have an htaccess file that uses mod_rewrite to redirect /controller to /index.php?controller=%controller% Like
I have a PHP client that requests an XML file over HTTP (i.e. loads
I have a PHP script that pushes the headers to allow a file to
I have some jQuery code. I have called an Ajax function file, file.php, that

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.