Page 1 of 1

how to execute method and store the value in variable

Posted: Wed May 16, 2007 12:25 am
by pleigh
hi, i was just wondering if i can store the value of the method in a variable. to make it clear, for examplpe i have a button with a method myMethod(), when i open a php page, that method is executed immediately even before clicking the button, and the value of that method will be stored inside a variable.

many thanks :)

Posted: Wed May 16, 2007 1:50 am
by feyd
Yes.

Posted: Wed May 16, 2007 4:03 am
by pleigh
thanks. may i ask for an example code? :D

Posted: Wed May 16, 2007 7:53 am
by volka
May we ask for the existing code first?

Posted: Wed May 16, 2007 11:49 am
by feyd
There are many examples in the manual, I would also bet that you have many examples in your code already.

Posted: Thu May 17, 2007 1:29 am
by pleigh
hi, thanks for the replies...an example method (available in php) will be appreciated.:)

if myMethod will generate a value "some values, some values, still some values", i just want that value to be stored in a variable the moment i open the php page.

Posted: Thu May 17, 2007 7:32 am
by Begby
POST YOUR CODE

Posted: Thu May 17, 2007 7:27 pm
by pleigh
ok thank you. here's the method

Code: Select all

getlog();
and here's the generated value of that record
reports.php?tab=td&rpt=16&sort=monthly&sortmonth=&sortweek=&startdate=&enddate=
before generating that value, i need to click on the button to trigger the getlogs() method. what i need to do is that when the page is loaded first time, that value will be generated and store it to a variable without clicking the button.

thanks.

Posted: Thu May 17, 2007 11:29 pm
by volka
Use the assignment operator to store the return value of a function or method in a variable.
see http://de2.php.net/manual/en/language.o ... gnment.php