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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:13:02+00:00 2026-06-12T00:13:02+00:00

I have 1 function which is having 1 parameter. I want to call this

  • 0

I have 1 function which is having 1 parameter.
I want to call this function from browser.
How can I call?
It is giving me blank.
When I write same code outside function , it is working.
Please help me.
I am passing this link to browser “domainname ://ipaddress/test.php/mywebservice”

i am using this code :

<?php

$json = '{"foo-bar": 12345}';

$obj = json_decode($json);
//print $obj->{'foo-bar'}; // 12345
switch($_GET['function']) {
case 'specificFunction':
    abc();
}

function abc
{
$con = mysql_connect("localhost","uname","Password");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}
//print_r($con);

mysql_select_db("roster", $con);



$query = "select * from rates";
$rs = mysql_query($query) or die($query);
//print_r($rs);
while($row=mysql_fetch_assoc($rs)){
$record[] = $row;
}

$data = json_encode($record);

header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
echo $data;
}
?>

Result :

{'foo-bar'}; // 12345 switch($_GET['function']) { case 'specificFunction': abc(); } function abc { $con = mysql_connect("localhost","uname","Password"); if (!$con) { die('Could not connect: ' . mysql_error()); } //print_r($con); mysql_select_db("roster", $con); $query = "select * from rates"; $rs = mysql_query($query) or die($query); //print_r($rs); while($row=mysql_fetch_assoc($rs)){ $record[] = $row; } $data = json_encode($record); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: application/json'); echo $data; } ?>

If I wirte:

<?php

$json = '{"foo-bar": 12345}';

$obj = json_decode($json);
//print $obj->{'foo-bar'}; // 12345

$con = mysql_connect("localhost","uname","Password");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}
//print_r($con);

mysql_select_db("roster", $con);



$query = "select * from rates";
$rs = mysql_query($query) or die($query);
//print_r($rs);
while($row=mysql_fetch_assoc($rs)){
$record[] = $row;
}

$data = json_encode($record);

header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
echo $data;

?>

Result :



[{"Month":"July","Year":"2012","Rate":"1.20%","Short":"0.24%","Mid":"0.92%","Long":"2.30%","RateUnFormatted":"0.012","LastUpdated":"2012-09-01 01:00:00","PublishFlag":"M"},{"Month":"June","Year":"2012","Rate":"1.20%","Short":"0.23%","Mid":"1.07%","Long":"2.64%","RateUnFormatted":"0.012","LastUpdated":"0000-00-00 00:00:00","PublishFlag":""},]

Which is correct.

  • 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-12T00:13:03+00:00Added an answer on June 12, 2026 at 12:13 am

    Call it from… (let me quote you) “outside function”.

    e.g.:
    page.php:

    include "file-containing-my-function.php";
    $param = $_GET['param'];
    myFunction($param);
    

    You can use a more general and much less secure method with passing the function name:

    With a request looking something like this: page.php?action=myFunction&param=value
    (or with rewrite engine you can achieve this same URL from a ://domain/page/myFunction/value request)

    page.php:

    $callback = $_GET['action'];
    $param = $_GET['value'];
    echo $callback($param);
    

    With this method you can call any function from your service with any first or single parameter with just changing the URL. But you also expose everything, so you should secure this request, by either checking the function’s name against user privileges, or check privileges in every single function you have. Same goes for the parameter of the function.

    There’s no direct way to specify a function to be called from a URL. You need to implement it for yourself, if you need a functionality like this, just as I did above.

    EDIT:

    I think I see what’s your question. Use rewrite engine. Add to your .htaccess

    RewriteEngine on
    RewriteCond %{QUERY_STRING} (.*)
    RewriteRule ^test.php/(.*)?$ test.php?function=$1&%1 [L]
    

    This will rewrite a query like:

    http://domain/page.php/myFunction?param=value

    to

    http://domain/page.php?function=myFunction&param=value

    Note that myFunction can also become “asd/asd/asd” (for a request like “page.php/asd/asd/asd?asd”) which is not a callable.

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

Sidebar

Related Questions

I want to call this function from OpenSSL library defined with prototy below: X509
Say I have a function in JS function playerJob(job){} I call this method from
I am having a classes which have function to make random text and captcha
Can I´m asking for advice. I have function which should return javascript object function
I have a function which looks something like this, it returns a noncopyable class
I have a function which repeatedly indexes into a dictionary with the same key.
Lets say I have a javascript function call moveItem which takes two parameters source
I have a function which gets object of some type as it parameter. I
hi i have function which is called by tinker listbox so i cannot return
I have a function which I have to loop it a few times but

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.