Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* All kind of function usages guide in php */
- <h2>simple function</h2>
- <?php
- function newFunction(){
- echo 'Hello World!';
- }
- newFunction();
- ?>
- <br>
- <h2>function argument 1</h2>
- <?php
- function newFunction2($arg){
- echo 'Hello '.$arg;
- }
- newFunction2('world!');
- ?>
- <br>
- <h2>function argument 2</h2>
- <?php
- function newFunction3($age1,$age2,$age3){
- echo $age1,$age2,$age3;
- }
- newFunction3('New ','Function ','3');
- ?>
- <br>
- <h2>Single Return function</h2>
- <?php
- function newFunction9($age1){
- $age = "$age1";
- return $age;
- }
- $output = newFunction9('single Return');
- echo $output;
- ?>
- <br>
- <h2>Multiple Return function</h2>
- <?php
- function newFunction4($age1,$age2,$age3){
- $age = "$age1 $age2 $age3";
- return $age;
- }
- $output = newFunction4('Return ','Function ','3');
- echo $output;
- ?>
- <br>
- <h2>Multiple Return array function</h2>
- <?php
- function newFunction5($age1,$age2,$age3){
- $age = "$age1 $age2 $age3";
- $info = "$age1 $age2 $age3";
- $data = "$age1 $age2 $age3";
- return array($age,$info,$data);
- }
- $output = newFunction5('Return ','Function ','3 ');
- echo $output[0];
- echo $output[1];
- echo $output[2];
- list($age,$info,$data) = newFunction5('Return ','Function ','3 ');
- echo '<br>';
- echo $age;
- echo '<br>';
- echo $info;
- echo '<br>';
- echo $data;
- echo '<br>';
- ?>
- <br>
- ***************************************************************************************************************************
- /* Function Usage guide in javascript */
- function my_Function(number1,number2){
- var result = number1 + number2 ;
- return result ;
- }
- // You can show data any where from the below
- alert(my_Function(400,500));
- confirm(my_Function(400,500));
- window.document.write(my_Function(400,500));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement