you pass a variable by value.

you pass a variable by value.

How do you pass a variable by value?

View Answers

December 27, 2010 at 5:48 PM

Hi friends,

Just like in C++, put an ampersand in front of it, like $a = &$b

/*--------------Pass By value----------------*/
function add($a)
{
return ++$a;
}
add($a);

/*---------------Pass by reference------------*/
function add(&$a)
{
return $a++;
}

add($a)

Thanks...









Related Tutorials/Questions & Answers:
you pass a variable by value.
you pass a variable by value.  How do you pass a variable by value... $a = &$b /*--------------Pass By value----------------*/ function add($a) { return ++$a; } add($a); /*---------------Pass by reference
How do you pass a variable by value?
How do you pass a variable by value?  How do you pass a variable by value
Advertisements
how to value of one variable pass in other variable in revetse order
how to value of one variable pass in other variable in revetse order  Like variable a=367 b must have valuev763
PASS value
PASS value  javascript to pass value to other html file
onclick pass variable - JSP-Servlet
onclick pass variable  on button onclick event pass variable and print in textbox in same page... i want to pass value of variable at onclick event of button and also want to print it in textbox in same page....  Hi
objective c pass by value
; //j now == 23, but this hasn't changed the value of i. } If you wanted to be able to modify i, you would have to pass the value of the reference by doing...objective c pass by value   How to pass value by reference
How to pass javascript variable in Scriplet of JSP?
How to pass javascript variable in Scriplet of JSP?  How can I assign the value of a javascript variable to a variable declared in jsp scriplet? Is it possible
pass by value /reference - Java Beginners
pass by value /reference  hello sir/mam, i know pass by value is a primitive type in java. what about pass by reference in java ? .. For object type pass by value is used or pass by reference is used ? pls give me a example
how to assign javascript variable value to a jsp variable
how to assign javascript variable value to a jsp variable  how to assign javascript variable value to a jsp variable
how to pass class variable to another class
how to pass class variable to another class  i need to access a variable from a class to another class currently running at the same time. using Classname.variable i got the value. But when i change the value second time i got
JSP Variable in Javascript
you to pass jsp variable to javascript. The JavaScript include a function... In this section, we are going to pass the jsp variable to javascript. You can see.... This  will display the value of string variable using the alertbox on loading
javascript variable value insertion in DB
javascript variable value insertion in DB  how can I insert javascript variable value into database using php
How to pass value of a link to a textfield
How to pass value of a link to a textfield  Dear Sir, in my project I'm initially making a value of the textfield as a link. Now, I want to pass the value of the link in the textfield after clicking the link and dont want to open
How to pass variable from one class to another in java
How to pass variable from one class to another in java  How to pass variable from one class to another in java?   Example: public class.... If there is public variable in Class1 then you can access them directly by Class1
Java Pass Value Example
Java Pass Value Example       Pass value from JSP to JavaScript We can also pass the value from a JSP page to the java script as we have done in our
I want to store the value of local variable into Global variable
I want to store the value of local variable into Global variable    <%=cnt%>=x; is it a valid Statement
Default value of path variable in Windows 7
Default value of path variable in Windows 7  Hi, In Windows 7 i... and its saying invalid command. What is the default value of the path variable in the Windows 7?   Hi, The default value of the path variable in windows
Getting environment variable value from java
Getting environment variable value from java  Getting environment variable value from java
i want to pass Javascript value to JSP scriptlet..
i want to pass Javascript value to JSP scriptlet..  i am having... that i am calling the onchange function. In javascript i am getting the value now i want to pass this value to JSP scriptlet
How to set a variable value using velocity
How to set a variable value using velocity       This Example shows you how to set variable value... with  character $. $list: This statement is used for display the value
In Struts 2 how to pass the <s: property value=''
In Struts 2 how to pass the s: property value'  In Struts 2 how to pass the s: property value' I have page where i display the list of treasury, their names. I need to have them as hyperlinks ans on click of A treasury name i
pass a variable(friends name) through a hyperlink in to another jsp.
pass a variable(friends name) through a hyperlink in to another jsp.  ... this code: while(resultset.next()) { %> <a href="home2.jsp?value... in to the next page,but i want to pass a specific friend name which i was clicked,plz tell
pass a variable(friends name) through a hyperlink in to another jsp.
pass a variable(friends name) through a hyperlink in to another jsp.  ... this code: while(resultset.next()) { %> <a href="home2.jsp?value... page,but i want to pass a specific friend name which i was clicked,plz tell me
How to pass value from dijit.Tree to dijit.MenuItem - Ajax
How to pass value from dijit.Tree to dijit.MenuItem  Hi Friends, I... with the menu. But I want to pass the value of an item to its menu item and when user will clik on that menu, the value should be shown like Delete Instead
How to pass the value from controller to jsp page ?
How to pass the value from controller to jsp page ?  HI I need to pass the value from controller to jsp. I use the way like this Controller request.setAttribute("msg", "Successfully Login"); In jsp ${msg} and then i
How to pass the value of Selected Value of combo box into sql ??
How to pass the value of Selected Value of combo box into sql ??  My SQL Database Name is MHS, user=root, password=admin,table name is sub_comb(regno,sname,sgen). Now i want to select one "regno" from Combobox and then after
write a program to demonstrate call by value and call by reference.(pass objects as parameters)
write a program to demonstrate call by value and call by reference.(pass objects as parameters)  write a program to demonstrate call by value and call by reference.(pass objects as parameters
How many ways we can pass the variable through the navigation between the pages?
How many ways we can pass the variable through the navigation between the pages?  How many ways we can pass the variable through the navigation between the pages
unable to get value returned from javascript variable in page
unable to get value returned from javascript variable in page  Hi, I have 3 pages....i wrote a js function to get the value of radio button from one... the value of the radio button from fisrt page to be stored in a variable so
If the variable $a is equal to 5 and variable $b is equal to character a, what?s the value of $$b?
If the variable $a is equal to 5 and variable $b is equal to character a, what?s the value of $$b?  If the variable $a is equal to 5 and variable $b is equal to character a, what?s the value of $$b
Assign value from a <bean:write> tag to a variable
Assign value from a tag to a variable  I am calling a stored procedure from JSP page which needs an input parameter. This input parameter needs to get the value from bean write tag . How can i do that ?   Please go
Pass value from JSP to JavaScript
Pass value from JSP to JavaScript       We can also pass the value from a JSP page to the java... a function hello() which takes value from the jsp page on click of some button
Assigning a value to JSP variable from a bean class. - JSP-Servlet
Assigning a value to JSP variable from a bean class.  Hi, I want to know how we can assign value to a JSP variable from a Java Bean. I am using Struts, JSTL. Which tags should I use to assign the value. e.g Kindly
how to pass variable from simple java main class(not servlet) to the jsp page?
how to pass variable from simple java main class(not servlet) to the jsp page?  I have a simple Java class in which I invoke a call to a JSP page, by launching a browser. I have this part working, but now I want to pass variables
JSP Value to JavaScript
;       JSP Value to JavaScript tells you to pass the value from JSP to JavaScript. The JavaScript create a function... In this section, we are going to pass the jsp value to javaScript. For this we
Pass value from child to parent window
Pass value from child to parent window       Java example program to pass value from child window... the parent window and will take the value to pass it on to the parent window
Local Variable and Instant Variable
not get an initial value, so if you use them in your code without initializing...Local Variable and Instant Variable  difference between Local Variable and Instant Variable   Difference between local variable
Can I pass a
Can I pass a   Suppose I have servlet named Name.java and there is a variable String name holding a value "Roseindia". I have collected the value to Getname.jsp via ajax. Now how can I pass this value to scriplet without page
I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?
I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what?s the problem?  I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what?s
I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?
I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what?s the problem?  I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what?s
Pass value of rasio button from jsp page to action class(not conventional problem)
Pass value of rasio button from jsp page to action class(not conventional...;table border="1"> <tbody> <s:iterator value...; <td><s:property value="#id.startTime" /></td>
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?  How to change the value of a variable... the value in jsp by using jstl method for eg:'<'c:set var="name1" value="Add User
How do you add a numerical value to a regex
How do you add a numerical value to a regex  how do you add a numerical value in a regex. I want to replace my pics ex: bob.jpg susan.jpg mike.jpg with 1.jpg 2.jpg 3.jpg etc. Thanks
Pass by Reference - Java Beginners
Pass by Reference  Hi Friends, What is Pass by value and Pass by Reference?can u please explain with examples.is java supports Pass by reference?  Hi Friend, Pass By Value: It refers to pass the variables
Passing variable
Passing variable  How to pass variable to HTTP object in HTMl or PHP
PHP Variable Functions
PHP Variable Functions: Learn PHP Variable Function means that if a variable name has a format like this $var(), PHP will consider this as a variable function... to execute it. This variable function does not work with echo(), print(), unset
PHP Variables Default Value
default value in PHP variables or Functions. If there is no value in the variable... which has only one variable or you can say argument variable that is $current_visitor. In the function call we passed the variable value called Suraj
Example program to pass value from Html to java script
Example program to pass value from Html to java script... which will pass the value to the java script function and this value...;TITLE> Pass value from HTML to JavaScript </TITLE> <script
Java variable
Java variable   To what value is a variable of the String type automatically initialized
PHP Variable Global
variable will refer to the global version. You can declared unlimited numbers... $test variable twice in the code to initialized the value. The first $test...PHP Global Variables PHP Global variable are the variables which can be used

Ads