Hi...
I have a php script which has a function call and function returns a value.
But when i open it in browser and refresh the page the return value will get added to the old value.
Code is: -
<? php
-
-
include("function.php");
-
-
$res=0;
-
-
$res=function::fn_call()
-
-
echo $res;
-
-
?>
-
When i run it in Terminal i will always get the desired value, but when i run it on browser. first time it displays currect value and on page refresh it adds the return value to old returned value.
i.e if return value echoed for 1st time is 4000 after page refresh i displays 8000, after next refresh 12000 and so on.
Script runs perfectly in terminal.
I am hosting pages on nginx and server log do not say anything as error.
Any idea why it behaves strangly?
Regards
Dheeraj
19 2015 Markus 6,050
Recognized Expert Expert
What is the contents of function.php?
It is a wrapper for set of C functions.
Markus 6,050
Recognized Expert Expert
As a guess (because you failed to answer my previously question sufficiently), I'd say the problem is this: the SAPI that a web server uses is continuous, as opposed to the SAPI that CLI uses, which is request-based. Therefore, it's how you're implementing those C wrappers that is the problem, but I cannot be any more specific because I am in no way shape or form an expert on Zend extensions (I only know a little).
I recommend you read the book 'Extending and Embedding PHP' - google will show you where to get it (although it is slightly outdated).
Mark.
I am using SWIG to Wrap my C functions.
And one more thing what i dont understand is why it gives desired output in the terminal not in browser?
Markus 6,050
Recognized Expert Expert @dheerajjoshim
Like I said, from what I can remember (I will have to read it again), a web-server uses a continuous SAPI, that is, once the server is started, any memory it uses is not reclaimed until the server is stopped/restarted, unless the memory is explicitly freed by the server/extension. So, if a C extension uses some memory when the server cycle starts and doesn't free it at the end of a request (I will explain about this more when I have re-read the book), the memory is retained.
The CLI (terminal/command-line) SAPI is started and stopped with each request - therefore, Zend frees up it's memory when the cycle ends - when the script you're executing ends.
But don't quote me on any of that.
Mark.
P.S. It's hard to explain something when you don't fully remember / understand what you read - so, hopefully, I'll make more sense when I have read it again.
Ok.
Thanks for some info Mark...
Does somebody out there knows a solution for this problem?
Markus 6,050
Recognized Expert Expert @dheerajjoshim
... if we saw the source-code, then we might be able to help; we're not psychics.
Definitely not psychics.....
All i wanted to know is did somebody got a problem like this in past?? if yes, how they tackled it..
Do you have any insight about problem?
Dormilich 8,658
Recognized Expert Moderator Expert
nope, haven’t done anything as such yet.
Ok....
Hope Somebody knows the solution.
Markus 6,050
Recognized Expert Expert @dheerajjoshim
Look, what I'm telling you is: if we do not see the source-code, the chances of us being able to help you are incredibly slim.
Which source code?
C or PHP?
Sorry mark, cant give c code.. It belong to somebody else.... I dont have permission to upload it in internet.
@dheerajjoshim
Then how will we understand your problem...
Try to make a mock code that generates the same problem and upload it... even that can help us to solve your problem.
I got a work around to deal with this problem.
I am getting correct results now.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Neil Schemenauer |
last post by:
python-dev@python.org.]
The PEP has been rewritten based on a suggestion by Guido to change
str() rather than adding a new built-in function. Based on my
testing, I believe the idea is...
|
by: Sara |
last post by:
I have a query that pulls data for the month, using the Month End Date
from a form (user enters) as criteria. It works. I want to use the
same query to pull "month to date" data, on a weekly...
|
by: Esteban404 |
last post by:
I have a Winform news kiosk app which connects to a SQL database. When the
main form is running, it reaches a threshold time or number of sequential
operations and then loads another instance with...
|
by: WLF |
last post by:
I have the following function (C# behind aspx page):
private void ButtonNewSupplier_Click(object sender, System.EventArgs
e)
{
Response.Write("<script...
|
by: siaj |
last post by:
Hello,
I have a javascript function for a validation in the HTML page of the
asp.Net page..
I call this function in a Savebutton click
When the validation fails No postback should happen ( ie...
| |
by: weston |
last post by:
I've got a piece of code where, for all the world, it looks like this
fails in IE 6:
hometab = document.getElementById('hometab');
but this succeeds:
hometabemt =...
|
by: mosesdinakaran |
last post by:
Hi everybody,
Today I faced a problem where I am very confused and I could not
solve it and I am posting here....
My question is
Is is possible to return a value to a particular function
...
|
by: sanjay.vasudevan |
last post by:
Why are the following declarations invalid in C?
int f();
int f();
It would be great if anyone could also explain the design decision
for such a language restricton.
Regards,
Sanjay
|
by: Davy |
last post by:
Hi all,
I am writing a function, which return the pointer of the int. But it
seems to be wrong. Any suggestion?
int * get_p_t(int t) {
return &t;
}
int main()
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |