Function Call by Value and Call by Reference in PHP

More than thousands of built-in functions prove the power of PHP Language. Besides built-in function PHP allows to create user defined function. How to create user defined function with example was explained in previous article. I also explained how to use variables inside a PHP function properly. Function call by value and call by reference is another important terms in PHP programming. So, in this article I will discuss how to call PHP function by value and by reference with example Function call by value in PHP If any PHP function accepts parameters, we usually send arguments when function is called. If we send values as arguments when function is called, it is known as function call by value. With function call by value technique, the value of a variable that is sent as arguments keeps unchanged although it is altered in function body. We usually use function call value technique most of our PHP programs. The following code is an example of function call by value in PHP. Output Inside function: 20 Outside function: 10. In the above program, the addTen() function is being called with a variable named $num. After calling the function, the variable is being printed […]

Continue reading


PHP Function Explanation

Real power of a programming language comes from its functions. More than 1000 built-in functions defined in PHP language prove the power of PHP language. Besides built-in function PHP has capability to declare user defined function like other programming language. So, PHP becomes a dominating programming language having a number of built-in functions and user defined function capability. A newbie PHP programmer should have enough skill on PHP functions along with other PHP basic items because PHP program frequently uses built-in function as well as user defined function. In my previous article I explained PHP loop statements elaborately and in this article I will discuss details on PHP functions.     PHP Function A function is a block of statement that takes one or more input values in form of argument and does some processing and then returns a value. PHP function can be divided into the following two categories. Built-in function User defined function PHP Built-in Function Built-in functions are those functions whose definition is predefined in PHP. More than thousands of built-in functions are present in PHP. Built-in function has predefined arguments and return that we have to know before usage. If you do practice regularly, you will able to […]

Continue reading